Darren Wanner wrote: > > I'm trying to write a simple script that takes a list of users from a file > and creates a user account for them, using the useradd script. The system > I'm doing this on is Solaris 8. When I run the script I get the following > error. It seems as if it's not accepting the variable in the command > line. I'm pretty new to all of this so any help would be greatly > appreciated. > > Error Message: > > UX: useradd: ERROR: invalid syntax. > usage: useradd [-u uid [-o] | -g group | -G group[[,group]...] | -d dir | > -s shell | -c comment | -m [-k skel_dir] | -f inactive | > -e expire | -A authorization [, authorization ...] | > -P profile [, profile ...] | -R role [, role ...]] > -p project [, project ...] login > useradd -D [-g group | -b base_dir | -f inactive | -e expire > -A authorization [, authorization ...] | > -P profile [, profile ...] | -R role [, role ...]] | > -p project > sh: -m: not found > > Simple add user script: > > #!/usr/bin/perl
You should enable warnings and strictures when developing new programs. #!/usr/bin/perl -w use strict; > open(FILE,"users.log"); You should _always_ verify that the file opened correctly. open FILE, 'users.log' or die "Cannot open users.log: $!"; > @users=<FILE>; If you a user per line in the file then you will have to remove the newlines at the end of the user names. chomp( my @users = <FILE> ); > foreach $users (@users) { > `useradd -g 201 -d /userhome/$users -m $users`; If you don't want the output from the command then you should use system() instead of backticks. system( qw[useradd -g 201 -d], "/userhome/$users", '-m', $users ) == 0 or die "system useradd failed: $?"; > } > print "done.\n"; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]