1
I have this code inside a file called test.sh When I try to execute
nohup ./teste.sh &
he makes that mistake. Someone can explain to me ?
./test.sh: 9: . /test.sh: Syntax error: Bad for loop variable
CODE
cuda="cuda.out";
cpu="cpu.out";
cudaTxt="cuda.out.txt";
cpuTxt="cpu.out.txt";
trash="/dev/null";
rm -f $cudaTxt;
rm -f $cpuTxt;
is ((i=10001;i<=1000001;i+=10000)); of echo "Cuda, $i iteration"; head -n$i formulas.txt > formulas_pre-processed_CUSTOMIZADA.txt; echo -en "$i t" >> $cudaTxt; . /$Cuda | cut -C19- >> $cudaTxt; done;
is ((i=10001;i<=1000001;i+=10000)); of echo "CPU, $i iteration"; head -n$i formulas.txt > formulas_pre-processed_CUSTOMIZADA.txt; echo -en "$i t" >> $cpuTxt; . /$cpu | cut -C19- >> $cpuTxt; done;
echo "Over";
Which shell you’re using?
– Marcelo Shiniti Uchimura
Ubuntu 16.04 , his normal shell, I don’t know if that answers your question ...
– Tequelequeteque
You tried to run without the
nohup
to see if it is the same problem? And to know which shell you are using, runecho $SHELL
orecho $0
and see what the output is. Some shells have slightly different syntaxes and the script won’t always work the same at all. A tip is to put in the first line of the script the shell you want to use to run it (for example:#!/bin/bash
to use bash: http://e-tinet.com/linux/programacao-shell-script/ )– hkotsubo
Yes, I tried and ran. "echo $SHELL -> /bin/bash" 'echo $0 -> -bash"
– Tequelequeteque
@hkotsubo I put #!/bin/bash and it worked But why ?
– Tequelequeteque
@Tequelequeteque I believe that the comments in Marcelo’s answer below clarify his doubt. When vc runs the direct command (no nohup), bash runs the script (since the shell you are using is bash). But when you run with nohup, it uses some other shell than bash (and this other shell does not recognize this syntax of
for
). But putting#!/bin/bash
at the beginning of the script, you say it should always be run by bash, and then it works.– hkotsubo