|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
script probs passing arguments into a loop...
Hi, I'm working on Solaris 5.8, and I'm having a problem running a script.
I've got a for loop that runs a command, which i need to pass arguments into that command. I'm having problems with those arguments not passing correctly, altho they are echoing correctly... The output from the command shows that the defaults to the command are being passed only, and not the called arguments that I'm trying to pass via the for loop... Here's the meat of it: for loop in "-a 2 -s 3 -x .5" "-a 2 -s 3 -x .75" "-a 3 -s 3 -x .5" " -a 3 -s 3 -x .75" do <command> $loop -t 4 -r all done **************************** the $loop, "-t 4", and "-r all" are all options I'm basically trying to pass to the command. It appears that the options part of the do loop are being passed as arguments correctly (the "-t 4" and the "-r all), however the options in the $loop are NOT being passed as arguments correctly. For now I've tried the various ways to solve this prob: 1) echo the options through a variable for loop in "-a 2 -s 3 -x .5" "-a 2 -s 3 -x .75" "-a 3 -s 3 -x .5" " -a 3 -s 3 -x .75" do $options=`echo $loop` <command> $options -t 4 -r all done 2) also tried all different ways to represent the value, in a variable: $loop "$loop" ${loop} "${loop}" ******************************* Is this possible to be done in bourne shell?? Or is there a different way to pass arguments??? Ugh.. Thanks in advance! Unseen_Swordsman |
|
#2
|
|||
|
|||
|
RE: script probs passing arguments into a loop...
Oh yes, I've also tried the following two different ways below. The problem with this method, is that the loop command ends up passing EACH argument to the command, not as a whole string of options, but argument by argument. For example, "-a 2 -s 3 -x .5" becomes: $1="-a", $2="2", etc... When the command executes, it runs each different argument separately, and basically errors out.
Any help appreciated! Unseen_Swordsman examples: ######################### a2s3x5="-a 2 -s 3 -x .5" a2s3x75="-a 2 -s 3 -x .75" THRESHOLDS="$a2s3x5 $a2s3x75" for loop in $THRESHOLDS do <command> $loop -t 4 -r all done ************** a2s3x5="-a 2 -s 3 -x .5" a2s3x75="-a 2 -s 3 -x .75" THRESHOLDS="${a2s3x5} ${a2s3x75}" for loop in $THRESHOLDS do <command> $loop -t 4 -r all done |
|
#3
|
|||
|
|||
|
RE: script probs passing arguments into a loop...
is this pseudocode or another language (not PHP)? Why don't you post your php code? I for one cannot make head or tail of this.
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Server Administration > script probs passing arguments into a loop... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|