LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-26-2004, 02:32 PM   #1
gearoid
Member
 
Registered: Nov 2003
Location: Ireland
Distribution: Red Hat 9
Posts: 49

Rep: Reputation: 15
scripting question


hey,

Ok, I'm sorry if this sounds like a lazy question but I need some pointers....

How would I create a file at startup, based on the name of the user logging in and the login time. A quick goole tells me that the commands 'who' and 'lastlog' will tell me this info at the cli, and I know that these commands use data from files in the /dev directorey to get this information. But where would I look in the /dev directory to find this out.

Also, I ultimately want to put the code to create this file in a shell script that will run at startup. Where would I put this script so that it will be run each time a user logs in?

Thanks,
Gearóid
 
Old 05-26-2004, 02:38 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
How about:
echo User `whoami` logged in at `date` > /path/to/file

If you just want to know when people logged in then use the "last" command.
 
Old 05-26-2004, 02:41 PM   #3
gearoid
Member
 
Registered: Nov 2003
Location: Ireland
Distribution: Red Hat 9
Posts: 49

Original Poster
Rep: Reputation: 15
beautiful, as simple as that!! Thanks david

so I'll just enclose that in a little shell script, but my next question is where would I place this script, or how would I configure it to run each time a user logs in?
 
Old 05-26-2004, 02:43 PM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
/etc/bashrc is run each time a shell is opened.
 
  


Reply



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
scripting question... Basslord1124 Linux - Networking 2 11-09-2005 05:52 AM
Scripting question mithereal Linux - General 2 09-21-2005 02:02 AM
Scripting question msandford Linux - Newbie 4 09-05-2005 10:23 AM
Scripting question.... Darklight451 Linux - Newbie 2 09-13-2004 11:29 PM
Scripting question glock19 Linux - Software 2 09-05-2003 12:45 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:11 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
Open Source Consulting | Domain Registration