Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 6 Aug 2002 14:49:52 +0100
From:      Neil Darlow <neil@darlow.co.uk>
To:        freebsd-questions@freebsd.org
Subject:   RE: ksh scripting arguments
Message-ID:  <200208061349.g76Dnrkb032678@router.darlow.co.uk>

next in thread | raw e-mail | index | archive | help
On 08/06/2002 at 05:53:51, 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

You should be testing $# for determining the number of arguments e.g.:

if [ $# -eq 0 ]; then
    echo "you must put an argument on the command line."
    exit
fi

Regards,
Neil Darlow M.Sc.
-- 
Say No to Software Patents -- Say No to TCPA -- Say No to Palladium
ICQ: 135505456  E-Mail, Jabber, MSNM: neil@darlow.co.uk
GnuPG Fingerprint: 359D B8FF 6273 6C32 BEAA  43F9 E579 E24A 531F 9048

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?200208061349.g76Dnrkb032678>