Date: Tue, 6 Aug 2002 08:53:51 -0400 From: "Phil Gates" <p_gates@fuse.net> To: <freebsd-questions@FreeBSD.ORG> Subject: ksh scripting arguments Message-ID: <001501c23d48$50c93b20$5d7e880a@zoomtown.com>
next in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format. ------=_NextPart_000_0012_01C23D26.C9854080 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable 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.=20 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 ------=_NextPart_000_0012_01C23D26.C9854080 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=3DContent-Type content=3D"text/html; = charset=3Diso-8859-1"> <META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR> <STYLE></STYLE> </HEAD> <BODY bgColor=3D#ffffff> <DIV><FONT face=3DArial size=3D2> Hi I am writing a = ksh script and=20 I am having a problem with a if statement. when I run the script = you need=20 to put a argument on the command line. So inside the script I try = to make=20 sure that a user is putting a argument on the command line with a if = command.=20 The if command is below:</FONT></DIV> <DIV><FONT face=3DArial size=3D2>if [$1 -z ]</FONT></DIV> <DIV><FONT face=3DArial size=3D2>then</FONT></DIV> <DIV><FONT face=3DArial size=3D2>echo "you must put a argument on the = command=20 line."</FONT></DIV> <DIV><FONT face=3DArial size=3D2>exit</FONT></DIV> <DIV><FONT face=3DArial size=3D2>fi</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>the if statement work fine if there no = argument. it=20 will print out the echo statement. On the other handif I put a = argument on=20 the command line it will print out the argument and say command is not = found.=20 </FONT></DIV> <DIV><FONT face=3DArial size=3D2>example of command line and = statement</FONT></DIV> <DIV><FONT face=3DArial size=3D2>$command argument</FONT></DIV> <DIV><FONT face=3DArial size=3D2>print out to screen</FONT></DIV> <DIV><FONT face=3DArial size=3D2>argument is not found</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>I have done ksh scripting on a hp-us = machine and I=20 never had this problem before. Has it something how the Unix = machine is=20 setup. It seems like the machine does not like any thing that is = not a=20 command. It does the same thing if I assign a variable. in the = program. So=20 the program is fine if I do no error checking i.e unix command only , = but if I=20 use any ksh scripting command it seems to work = different.</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>If anyone can help please email = back</FONT></DIV> <DIV><FONT face=3DArial size=3D2></FONT> </DIV> <DIV><FONT face=3DArial size=3D2>Thanks</FONT></DIV> <DIV> </DIV></BODY></HTML> ------=_NextPart_000_0012_01C23D26.C9854080-- 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?001501c23d48$50c93b20$5d7e880a>