LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Trap Commands (https://www.linuxquestions.org/questions/linux-newbie-8/trap-commands-4175494717/)

dchawk 02-12-2014 09:05 PM

Trap Commands
 
I have very little background using Linux and I am having a bit of an issue. I am trying to utilize the trap command to display a list of logged on users each time I log out. I was attempting to us trap ls/who exit. However, this does nothing for what I am trying to do. Any help would be greatly appreciated!!

grail 02-12-2014 09:11 PM

Please show your code? Just the trap, what signal it is being called on and what function you call the trap to perform.

dchawk 02-12-2014 10:12 PM

Trap is brand new to me so I have no clue.

btmiller 02-12-2014 10:27 PM

I am not sure why you're using a trap command to do this. Assuming that you're running the bash shell, you can create a file called .bash_logout in your home directory and them put the ls and who commands in it. That file will be run every time you log out, and the output of those commands will be displayed in your terminal.

grail 02-12-2014 11:20 PM

Quote:

Trap is brand new to me so I have no clue.
If this is the case I would say you need to hit up the man page and also any bash reference material on how to use trap ([url=http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_12_02.html]here[\url] is one such resource)

As mentioned above, you may be trying to use the wrong tool for the job, but you should at least read up on something prior to using it and asking questions which may be in general literature.

dchawk 02-13-2014 10:05 PM

Ok, at the prompt I entered :$bash
then at the 2nd prompt:$ trap who exit
lastly :$ exit (which provided a list of logged on users)

grail 02-13-2014 11:51 PM

So your issue is solved? Please mark as such from the Thread Tools


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