The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
What happens when user logout? yhacks Linux 1 05-16-2008 02:20 AM
Executing script with root privilages from a user login checkpro SCO 1 03-11-2008 06:03 PM
Shell script to find when user su'ed to root jrvilino Shell Programming and Scripting 1 03-05-2008 10:31 AM
root executes a script as another user tads98 Shell Programming and Scripting 1 05-17-2005 08:54 AM
Canīt logout to user inactive lalox UNIX for Dummies Questions & Answers 1 07-31-2004 09:31 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-09-2008
harsha10 harsha10 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 8
run a script on logout by a non-root user

hi ,
i need to run a script that delete files when i logout as a user other than root user .

I have tried out using .bash_logout but that doesnt seem to work , so any alternative for this to be done.

Thanks in advance,
Harsha
  #2 (permalink)  
Old 06-10-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
You can set a trap in /etc/profile:

Code:
trap 'rm -f $HOME/.dotfile1 $HOME/anotherfile; exit 0' 0
The trap for "signal 0" will be executed when the shell exits.
  #3 (permalink)  
Old 06-16-2008
harsha10 harsha10 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 8
Thats true , but what i need is ,

to write the 'trap rm' command (as mentioned in your reply ), in the file which is accessible by a normal user .

I need to insert this command through my program as a normal user.
(/etc/profile can be changed only by the root!!)

Is there any way out for this prob?
  #4 (permalink)  
Old 06-16-2008
nua7 nua7 is offline
Registered User
  
 

Join Date: Mar 2008
Location: /bin/sh
Posts: 353
Try sourcing the .bash_logout file

Did you source the .bash_logout file..?

If source option is not avalaible, depending on your OS, try this:

Code:
~./bash_logout
  #5 (permalink)  
Old 06-16-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
If you want to set a trap for a single user, you can add it to the user's $HOME/.profile

Perhaps you could explain a bit more about the problem you are trying to solve.

If you are using bash and the .bash_logout is not being executed, that is of course also something to look into.
  #6 (permalink)  
Old 06-16-2008
harsha10 harsha10 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 8
Need to make a script run from my program which deletes certain files as and when the user logouts from the GNOME log screen.

This program is run by a normal user (not the root user).

If I write the required commands in $HOME/.profile , the files get deleted when ever the user logs in again , but i need to delete the files immediately after the user logs out.

i believe .bash_logout doesnt not work if we use GNOME log screen for logging off.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:25 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0