From owner-freebsd-questions Tue Aug 6 6:57:51 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 CDB5A37B400 for ; Tue, 6 Aug 2002 06:57:47 -0700 (PDT) Received: from hercules.icarz.com (ns1.icarz.com [207.99.22.7]) by mx1.FreeBSD.org (Postfix) with ESMTP id 99E8043E5E for ; Tue, 6 Aug 2002 06:57:46 -0700 (PDT) (envelope-from blairw@icarz.com) Received: from icarz.com (dhcp107.icarz.com [207.99.22.107]) by hercules.icarz.com (8.11.6/8.10.1) with ESMTP id g76CiVT05964; Tue, 6 Aug 2002 08:44:31 -0400 (EDT) Message-ID: <3D4FC4AF.403@icarz.com> Date: Tue, 06 Aug 2002 08:44:31 -0400 From: William Blair Wagner User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:0.9.4.1) Gecko/20020508 Netscape6/6.2.3 X-Accept-Language: en-us MIME-Version: 1.0 To: Phil Gates Cc: freebsd-questions@FreeBSD.ORG Subject: Re: ksh scripting arguments References: <001501c23d48$50c93b20$5d7e880a@zoomtown.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit 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 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