Search Results

Search found 2 results on 1 pages for 'newshellscripter'.

Page 1/1 | 1 

  • Shell Scripting For loop Syntax Error

    - by NewShellScripter
    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!

    Read the article

  • Shell Scripting: Generating output file name in script and then writing to it

    - by NewShellScripter
    Hello, I have a shell script where a user passes different sizes as command line arguments. For each of those sizes, I want to perform some task, then save the output of that task into a .txt file with the size in the name. How can I take the command line passed and make that part of a stringname for the output file? I save the output file in a directory specified by another command line argument. Perhaps an example will clear it up. In the foor lop, the i value represents the command line argument I need to use, but $$i doesnt work. ./runMe arg1 arg2 outputDir [size1 size2 size3...] for ((i=4; i<$#; i++ )) do ping -s $$i google.com >> $outputDir/$$iresults.txt done I need to know how to build the $outputDir/$$iresults.txt string. Also, the ping -s $$i doesnt work. Its like I need two levels of replacement. I need to replace the $[$i] inner $i with the value in the loop, like 4 for ex, making it $4. Then replace $4 with the 4th command line argument! Any help would be greatly appreciated. Thanks!

    Read the article

1