![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| TAHI Test Suite 3.0.13 (IPv6 Conformance Test Tool branch) | iBot | Software Releases - RSS News | 0 | 04-06-2008 09:20 AM |
| Keithley Introduces Linux-Based RF Parametric Test Systems - Test and Measurement.com | iBot | UNIX and Linux RSS News | 0 | 07-23-2007 07:30 AM |
| Variables being worked on inside of loops | yongho | UNIX for Dummies Questions & Answers | 7 | 06-13-2005 08:42 AM |
| useradd | dorilevy | UNIX for Advanced & Expert Users | 2 | 10-18-2004 11:15 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am trying to write a script that does a useradd -G <group> <user> but you cannot modify the user if he/she is logged on. How could I check to see if the user is on or if the user has been added to the group successfully? I plan on having the script sleep for a couple mins if the user is on then attempt to add the user to the group again.
Last edited by doublejz; 08-26-2005 at 07:03 AM. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
useradd sets the exit status. So just check the exit status as you would for any other well designed program.
|
|
#3
|
||||
|
||||
|
Quote:
Code:
if useradd <args>; then do stuff else do other stuff fi |
|
#4
|
||||
|
||||
|
Hi !
In addition to what vertigo23 and perderabo said, you can check the $? variable. This will tell you the error code returned by the last command (in your case, useradd). If the result is 0, then the last command exited without any error. If it tells you something else, check the manual pages or google to see what it means. |
||||
| Google The UNIX and Linux Forums |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|