LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Script is executed when user logout (https://www.linuxquestions.org/questions/linux-newbie-8/script-is-executed-when-user-logout-568006/)

karthi26 07-10-2007 12:17 AM

Script is executed when user logout
 
Hello guys,

Could anybody help me create a script that moves the files and directory from the user home directory to /usr/local/. this should get executed when the user logout.point me to a similar one I can modify, or indeed write one for me a script that will move files when user logout.

Regards,
karthi

jschiwal 07-10-2007 12:58 AM

That isn't what /usr/local is for. Why do you want to move a users files? The /home directory is the place for a regular users files. /usr/local is where programs you build yourself often gets installed. It has a similar hierarchy structure as the the root directory and /usr.

karthi26 07-10-2007 01:08 AM

No the server is located remotely. l have to update the remote server web applications so the programmer has to upload the to user's home directory so that i can able to get the file's eventually files copied through script when user's get logout.if there is any other idea plz specify me

Regards,
karthi

jschiwal 07-10-2007 01:22 AM

If the shell used is bash, then if there is a ~/.bash_logout script, it will be run. This script won't have write permission to /usr/local, so you might want to create a directory in /home/ just for storing the files.

See the info bash manual. The ~/.bash_logout is run when an interactive shell is exited. That is what the login shell is. However a user might be using a different shell.

karthi26 07-10-2007 01:33 AM

ya the plan of running script is not possible unless i gave full permission to access /usr/local is there any other way so that i can place upload file to that directory.please help me solve this situation.

linusali 07-10-2007 06:36 AM

Hi,

Gives us some more details. Also it is very easy to move the files provided user have permission to do so, but this way you will end up having very insecure application, which is updated arbitrarily with out testing.

There are couple of methods for the job you are looking for
  1. As jschiwal said, it can be done through .bash_logout
  2. Another way is to have cronjob which runs every minute, run by a user who has permission to both folders - source and destination

In case if it is an development environment; then probably you need a SVN or CVS server, a staging server - for testing, and then the production server.

regards

karthi26 07-12-2007 12:26 AM

Hello guys,
Here the my requirements:
i have to secure my ssh for remote login.so i have blocked the remote login and allowed a user to login in remote and from there using sudo command changing to root user. Now the problem is the programmer have to update the web applications (java runs in tomcat ) so he uses the graphical ssh to upload the files but here the files are stored in the user's home directory. so those files has to be 'moved' to the /usr/local where the jakarta folder when the logout. then the higher offical can able to use those files for deploying in live server. but every time the user uploads and logs out the above scenario has to be processed.

If any further lockout information mention it and help me.

chrism01 07-12-2007 12:56 AM

why not just put user in sudoers file with restriction to only run file move script?

karthi26 07-12-2007 01:39 AM

i haven't tried with those sudoers thank you for idea and the new things i am going to work. If you helped me to study those things i can proceed to do things with you help.


thanks karthi26

chrism01 07-12-2007 05:24 AM

Read & enjoy: http://www.gratisoft.us/sudo/man/sudoers.html :)

karthi26 07-12-2007 07:26 AM

:) Thanks a lot.... for you all :study:


All times are GMT -5. The time now is 08:38 PM.