From owner-freebsd-questions Tue Aug 6 8:12: 8 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6F5FF37B400 for ; Tue, 6 Aug 2002 08:12:05 -0700 (PDT) Received: from router.darlow.co.uk (pc2-bigg2-0-cust101.ltn.cable.ntl.com [213.107.35.101]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5AA8343E65 for ; Tue, 6 Aug 2002 08:12:04 -0700 (PDT) (envelope-from neil@darlow.co.uk) Received: from there (IDENT:1000@ideal.darlow.co.uk [192.168.0.2]) by router.darlow.co.uk (8.12.3/8.12.3) with SMTP id g76Dnrkb032678 for ; Tue, 6 Aug 2002 14:49:54 +0100 (BST) (envelope-from neil@darlow.co.uk) Message-Id: <200208061349.g76Dnrkb032678@router.darlow.co.uk> Content-Type: text/plain; charset="iso-8859-1" From: Neil Darlow To: freebsd-questions@freebsd.org Subject: RE: ksh scripting arguments Date: Tue, 6 Aug 2002 14:49:52 +0100 X-Mailer: KMail [version 1.3.2] MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG 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