Cygwin bash help file

I have a bash file that I am trying to run in Cygwin on a Windows 7 platform, but I get some odd errors. The bash file works on my Linux system. The bach file looks like this:

for ((r=0; r <10; r++))

    netcat localhost 4444 < myfile.file &

done

wait

      

but Im getting an error for my for loop. More precisely, he writes:

./tuning_test.bsh: line 1: syntax error near unexpected token `('

'/tuning_test.bsh: line 1: `?for ((r=0; r <10; r++))

      

I don't understand this because I was sure that Ive worked with a bash file on my Linux. I even tried to find an example for a loop from the Linux-bash site and run it, but with the same error.

I'm completely new to Cygwin and don't know if it has little quirks or some other thing I should be aware of, and I tried looking through the documentation and FAQ on its home page.

Sincere

Mestika

+2


a source to share


4 answers


You seem to be missing the do

shebang line as well:



#!/bin/bash
for (( r=0; r<10; r++ ))
do
    netcat localhost 4444 < myfile.file &
done
wait

      

+4


a source


Yes, I found out that my text editor (notepad ++) was sitting with DOS / Windows formatting, I just changed it to UNIX and it worked :-)



+3


a source


you must mark the loop correctly with do .. done 'do' skipped

+1


a source


Perhaps the Cygwin bash version is much older than Linux? This works for me with MSYS bash:

for ((r=0; r <10; r++))
do
    echo $r
done

      

Note that I've added a keyword do

to the loop. You can also try writing your loop as:

for r in 0 1 2 3 4 5 6 7 8 9
do
    echo $r
done

      

+1


a source







All Articles