LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-10-2007, 12:17 AM   #1
karthi26
Member
 
Registered: Mar 2007
Posts: 62

Rep: Reputation: 15
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
 
Old 07-10-2007, 12:58 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
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.
 
Old 07-10-2007, 01:08 AM   #3
karthi26
Member
 
Registered: Mar 2007
Posts: 62

Original Poster
Rep: Reputation: 15
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
 
Old 07-10-2007, 01:22 AM   #4
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
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.
 
Old 07-10-2007, 01:33 AM   #5
karthi26
Member
 
Registered: Mar 2007
Posts: 62

Original Poster
Rep: Reputation: 15
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.
 
Old 07-10-2007, 06:36 AM   #6
linusali
LQ Newbie
 
Registered: Jul 2007
Location: Dubai
Distribution: Kubuntu - 9.04
Posts: 18

Rep: Reputation: 1
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
 
Old 07-12-2007, 12:26 AM   #7
karthi26
Member
 
Registered: Mar 2007
Posts: 62

Original Poster
Rep: Reputation: 15
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.
 
Old 07-12-2007, 12:56 AM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,406

Rep: Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396
why not just put user in sudoers file with restriction to only run file move script?
 
Old 07-12-2007, 01:39 AM   #9
karthi26
Member
 
Registered: Mar 2007
Posts: 62

Original Poster
Rep: Reputation: 15
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
 
Old 07-12-2007, 05:24 AM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,406

Rep: Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396Reputation: 2396
Read & enjoy: http://www.gratisoft.us/sudo/man/sudoers.html
 
Old 07-12-2007, 07:26 AM   #11
karthi26
Member
 
Registered: Mar 2007
Posts: 62

Original Poster
Rep: Reputation: 15
Thanks a lot.... for you all
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script run as user login or logout in Vsftpd server singhpps Linux - Software 4 11-27-2010 11:06 AM
Perl problem: script isn't executed but viewed jpostma Programming 10 02-08-2008 03:34 PM
zsh return 0 if script sourced not executed cs-cam Linux - General 2 08-12-2006 11:41 AM
hotplug script executed 3 times Borelian Linux - Software 1 06-28-2004 11:46 PM
Simple script to be executed on startup. Korff Linux - General 2 06-03-2003 09:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:41 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration