LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 02-12-2014, 10:05 PM   #1
dchawk
LQ Newbie
 
Registered: Feb 2014
Posts: 4

Rep: Reputation: Disabled
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!!
 
Old 02-12-2014, 10:11 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,252

Rep: Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685
Please show your code? Just the trap, what signal it is being called on and what function you call the trap to perform.
 
1 members found this post helpful.
Old 02-12-2014, 11:12 PM   #3
dchawk
LQ Newbie
 
Registered: Feb 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
Trap is brand new to me so I have no clue.
 
Old 02-12-2014, 11:27 PM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
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.
 
Old 02-13-2014, 12:20 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,252

Rep: Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685
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.
 
Old 02-13-2014, 11:05 PM   #6
dchawk
LQ Newbie
 
Registered: Feb 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
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)
 
Old 02-14-2014, 12:51 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,252

Rep: Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685Reputation: 2685
So your issue is solved? Please mark as such from the Thread Tools
 
  


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
[SOLVED] BASH - Invoke commands when trap is activated worm5252 Programming 1 10-04-2011 05:54 PM
how to send snmp trap & recieve trap in C program minil Programming 3 07-10-2010 10:22 AM
Kernel trap (Fatal trap 12) m!k@EL *BSD 4 09-06-2007 12:58 AM
kill-trap basak Linux - Software 10 08-23-2006 06:38 PM
trap command for c? onnyloh Programming 3 09-13-2004 05:06 AM


All times are GMT -5. The time now is 10:18 AM.

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