Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 06 Aug 2002 08:44:31 -0400
From:      William Blair Wagner <blairw@icarz.com>
To:        Phil Gates <p_gates@fuse.net>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: ksh scripting arguments
Message-ID:  <3D4FC4AF.403@icarz.com>
References:  <001501c23d48$50c93b20$5d7e880a@zoomtown.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Try this:

if [ $# -lt 2 ]
then
  echo "you must..."
  exit 255
fi
CMDARG=$1
...rest of your script

...I hope this helps :-)


Phil Gates wrote:

>     Hi I am writing a ksh script and I am having a problem with a if 
> statement.  when I run the script you need to put a argument on the 
> command line.  So inside the script I try to make sure that a user is 
> putting a argument on the command line with a if command.   The if 
> command is below:
> 
> if [$1 -z ]
> 
> then
> 
> echo "you must put a argument on the command line."
> 
> exit
> 
> fi
> 
>  
> 
> the if statement work fine if there no argument. it will print out the 
> echo statement.  On the other handif I put a argument on the command 
> line it will print out the argument and say command is not found.
> 
> example of command line and statement
> 
> $command argument
> 
> print out to screen
> 
> argument is not found
> 
>  
> 
> I have done ksh scripting on a hp-us machine and I never had this 
> problem before.  Has it something how the Unix machine is setup.  It 
> seems like the machine does not like any thing that is not a command. It 
> does the same thing if I assign a variable. in the program.  So the 
> program is fine if I do no error checking i.e unix command only , but if 
> I use any ksh  scripting command it seems to work different.
> 
>  
> 
> If anyone can help please email back
> 
>  
> 
> Thanks
> 
>  
> 


-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  William Blair Wagner : Education is not always knowing the answer,
  blairw@icarz.com     : ...but rather knowing where to look for it!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3D4FC4AF.403>