cbillson
July 16th, 2013, 04:47 PM
In Dos i could do the following: i need help translating this into linux shell.
test1=bob
test2=joe
test3=ken
test4=none
set var=0
:start
set var+=1
(Line below sets test to the value of test%var% - test1, test2 etc)
CALL SET test=%%test%var%%%
if %test% == none goto end
echo %test%
goto start
:end
this should:
echo bob
echo joe
echo ken
exit.
Apologies if what i've actually typed contains errors, what I'm trying to achieve is, a script that can repeat a number of tasks until it see's 'none' - but everything i want it to do will be based around a number.
I can easily work out how to increment a number, i need help repeating the bunch of tasks (for loop?) and breaking out of the routine.
as an example, lets use the loop to download files:
file1=test.zip
file2=winzip.exe
file3=none
file=$filex
wget http://8.8.8.8/$file
if [ -e $file ]; then filexresult=success; fi
echo $file $filexresult
(repeat)
How achievable is this, or am i going at this all wrong?
Thanks in advance.
test1=bob
test2=joe
test3=ken
test4=none
set var=0
:start
set var+=1
(Line below sets test to the value of test%var% - test1, test2 etc)
CALL SET test=%%test%var%%%
if %test% == none goto end
echo %test%
goto start
:end
this should:
echo bob
echo joe
echo ken
exit.
Apologies if what i've actually typed contains errors, what I'm trying to achieve is, a script that can repeat a number of tasks until it see's 'none' - but everything i want it to do will be based around a number.
I can easily work out how to increment a number, i need help repeating the bunch of tasks (for loop?) and breaking out of the routine.
as an example, lets use the loop to download files:
file1=test.zip
file2=winzip.exe
file3=none
file=$filex
wget http://8.8.8.8/$file
if [ -e $file ]; then filexresult=success; fi
echo $file $filexresult
(repeat)
How achievable is this, or am i going at this all wrong?
Thanks in advance.