On Wednesday 17 June 2009 18:29:40 Regina Miller wrote:
> Hi,
>
Hi!
First of all, you shouldn't use $ARGV[0] , $ARGV[1], etc. directly. Do:
{{{
my ($first_name, $last_name, $address) = @ARGV;
}}}
Which is a much more robust idea.
Secondly, look at the list form of system:
{{{
system("echo", "One two", "three four--five");
}}}
Hope it helps.
Regards,
Shlomi Fish
>
>
> My script to add a new user is below, written on solaris 10.
>
>
>
> Running it using either of these two ways (one with double quotes
> around the second parameter and one with single quotes):
>
> ./adduser.sh TestAcct "John Smith" Law
>
> ./adduser.sh TestAcct 'John Smith' Law
>
> My script thinks I have entered four parameters.
>
>
>
> But when I run it using the following (with no embedded spaces):
>
> ./adduser.sh TestAcct JohnSmith Law
>
> It then thinks I have entered three parameters.
>
>
>
> How do I get a parameter that has embedded spaces to register as just
> one parameter??
>
>
>
> Thanks for any help,
>
> Regina
>
>
>
> Regina Miller
>
> Lead Analyst, Grays Harbor County
>
> (360) 249-4144 ext 457
>
> rmiller@...
>
>
>
>
>
> MY SCRIPT
>
>
>
> eval "exec ctperl -S $0 $*"
>
> if $running_via_sh;
>
> #$Id: adduser.sh,v 302.4 1995/07/21 16:29:18 nick Exp $
>
> #require 'ctree.pl';
>
> ########################################################################
> ########
>
> # %perl
>
> # %width 80
>
> # %title Add a New User
>
> # %name adduser.sh
>
>
>
> use strict;
>
> use warnings;
>
>
>
> die 'Usage: adduser username "full name" group. i.e. adduser testacct
> "John Smith" Law'
>
> unless @ARGV == 3;
>
>
>
> unless (system "useradd -g $ARGV[2] -d /home/$ARGV[0] -m -s /usr/bin/ksh
> -c $ARGV[1] $ARGV[0]")
>
> {
>
> system "passwd $ARGV[0]";
>
> exit;
>
> }
>
> print "Error. User can not be added\n";
>
>
>
>
>
> [Non-text portions of this message have been removed]
--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
What does "Zionism" mean? - http://xrl.us/bjn8u
God gave us two eyes and ten fingers so we will type five times as much as we
read.