LinuxQuestions.org
Visit the LQ Articles and Editorials section
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 08-13-2002, 09:13 AM   #1
johnpayback
LQ Newbie
 
Registered: Jul 2002
Posts: 15

Rep: Reputation: 0
Question useradd command


Is there a way to execute another command after I execute the useradd command. I know that you can copy files from /etc/skel into the users home directory when you run useradd but can I make Redhat 7.2 execute another command as soon as it is done running the useradd command?

Thanks,

John
 
Old 08-13-2002, 09:19 AM   #2
X11
Member
 
Registered: Dec 2001
Location: Brisie, Australia
Distribution: Slackware 8.1
Posts: 324

Rep: Reputation: 30
You can use this: useradd && another command.
 
Old 08-13-2002, 09:27 AM   #3
johnpayback
LQ Newbie
 
Registered: Jul 2002
Posts: 15

Original Poster
Rep: Reputation: 0
Is there a way for me to hide that when the useradd command is executed? I don't think that there is but I thought that I would ask. I'm trying to keep my reps from having to learn anything new.
 
Old 08-13-2002, 09:39 AM   #4
X11
Member
 
Registered: Dec 2001
Location: Brisie, Australia
Distribution: Slackware 8.1
Posts: 324

Rep: Reputation: 30
Quote:
Is there a way for me to hide that when the useradd command is executed?
Not as far as I know.
 
Old 08-13-2002, 09:50 AM   #5
GabeF
Member
 
Registered: Mar 2002
Location: New Hampshire, US
Distribution: Mandrake 8.0, Redhat 8.0
Posts: 101

Rep: Reputation: 15
I don't know exactly how you do it, but if you wanted, you could write a shell script. Once you have the shell script setup, you could run it and it would run all the commands for you
Here is a site to help you do that:

http://linuxcommand.org/writing_shell_scripts.html

You could also try writing a perl script and run the commands that way. I don't know the specifics, but there are plenty of tutorials that will tell you how.

This is a short section I found in a Perl For Dummies 3rd Edition by Paul Hoffman:

"Perl makes it easy to run commands on you computer as if you had entered them on the command line. Perl's system function is designed to execute a command. On a [Linux] system, for example, you can use the system function execute the 'ls' command."

Here is a sample code snippet:

#list contents of var/www/html folder
system( 'ls -l /var/www/html' );

Of course, to use the Perl system function, you should know perl first. There is a short tutorial on www.devshed.com.

Hope this helps.
 
Old 08-13-2002, 10:22 AM   #6
johnpayback
LQ Newbie
 
Registered: Jul 2002
Posts: 15

Original Poster
Rep: Reputation: 0
Could I possibly add an option to the /etc/login.defs file so when the user logs in the first time then the command I need to run will run? Where could I find info on something like this assuming that it is possible?
 
  


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
useradd command Wolvastur Linux - Newbie 9 01-25-2005 10:01 AM
useradd command question hct224 Linux - Newbie 2 06-14-2004 04:47 PM
Useradd command not found. keysorsoze Red Hat 8 05-01-2004 03:17 PM
useradd command johnpayback Linux - General 4 08-13-2002 05:24 PM
useradd command allancondino Linux - General 5 04-27-2002 12:01 PM


All times are GMT -5. The time now is 12:31 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration