Shell Scripting For loop Syntax Error

Posted by NewShellScripter on Stack Overflow See other posts from Stack Overflow or by NewShellScripter
Published on 2010-06-08T17:20:35Z Indexed on 2010/06/08 17:22 UTC
Read the original article Hit count: 211

Filed under:
|

Hello, I am trying to make a simple shell script to ping a source but I am getting

bash-2.03$ ./test.sh google.com 10 .5 /home/users/me 16 256
./test.sh: line 35: syntax error near unexpected token `(('
./test.sh: line 35: `for (( i = 1 ; i <= $totalArguments ; i++ ))'

This is the code:

#!/bin/bash

ip=$1
count=$2
interval=$3
outputDirectory=$4
shift;
shift;
shift;
shift;
totalArguments=$#

for (( i = 1 ; i <= $totalArguments ; i++ ))
do 
    ping -c $count -i $interval -s ${!i} $ip >> $outputDirectory/${!i}results.txt
done

Can someone tell me what I am doing wrong with the for loop syntax? Thanks!

© Stack Overflow or respective owner

Related posts about bash

Related posts about shell-scripting