Re: Looping counter script ---- newbie question

From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 01/30/05


Date: Sun, 30 Jan 2005 09:11:16 -0500

In article <1107092485.308080.177190@f14g2000cwb.googlegroups.com>,
 masood.iqbal@lycos.com wrote:

> First of all my apologies for posting such a simple question. But I am
> new to scripting, so I may be excused.
>
> I have written a small script (by looking at my book) but I have
> obiously made some mistake since it does not run as expected. Any help
> will be appreciated.

Get rid of the spaces around the "=" in your variable assignments. You
got it right inside the while loop, but wrong everywhere else.

>
> Masood
>
> ###################################################
> #!/bin/ksh
>
> if [ "$#" -lt "2" ]
> then
> echo "Needs at least 2 command line arguments"
> exit 1
> fi
>
> begin = $1
> end = $2
>
> if [ "$2" -lt "$1" ]
> then
> echo "Second argument should not be less than first"
> exit 2
> fi
>
> val = $begin
>
> while [ $val -le $end ]
> do
> echo $val
> val=`expr $val + 1`
> done
>
> exit 0

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


Relevant Pages

  • Re: Adding a Key without overwriting what is already there
    ... registry value instead of creating yet another registry entry): ... On Error Goto 0 ... Exit For ' finished, exit the loop ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.win2000.registry)
  • Looping counter script ---- newbie question
    ... First of all my apologies for posting such a simple question. ... new to scripting, ... echo "Second argument should not be less than first" ...
    (comp.unix.shell)
  • Re: wbemtest and network adapter events
    ... > events coming through when I unplug my cable (the system tray sees ... ' enable the line below if you want to exit after the first event. ... -- torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway Administration scripting examples and an ONLINE version of the 1328 page Scripting Guide: ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Fetching 2 NIC values only
    ... The Exit For is there because I don't know how to display 2 categories only. ... >> cards on the machine, so my goal is to fetch the the first and second cards ... > torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Fetching 2 NIC values only
    ... for each blah blah ... Or - count the values you want and exit when you have as many as you need. ... >>> cards on the machine, so my goal is to fetch the the first and second ... >> torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway ...
    (microsoft.public.win32.programmer.wmi)