Register
It is currently Fri Apr 18, 2014 11:25 am

Create a logfile of USERADD


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Mon Feb 13, 2012 1:59 am   

Joined: Mon Feb 13, 2012 1:41 am
Posts: 1
Hello I've a problem with an script that should create users.
After a user is created it should be written into a logfile. Now I have the problem that I don't know how to use an IF to decide between "user already exists" or "user successfully created".

Here is a part of my script:

Code:
useradd $user -p `mkpasswd` -d /home/$user -m 2>log.txt

echo "Benutzer $user erfolgreich angelegt" >> log.txt


Thanks you for your help

Tobi


Top
 Profile  
 PostPosted: Mon Feb 13, 2012 5:38 am   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 512
hi,

simply use &&
Code:
useradd $user -p `mkpasswd` -d /home/$user -m 2>log.txt && echo "Benutzer $user erfolgreich angelegt" >> log.txt


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP