Server Administration
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesServer Administration

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 21st, 2003, 04:52 PM
unseen_swordsman unseen_swordsman is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: pasadena, CA, USA
Posts: 2 unseen_swordsman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to unseen_swordsman
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

Reply With Quote
  #2  
Old August 21st, 2003, 05:00 PM
unseen_swordsman unseen_swordsman is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: pasadena, CA, USA
Posts: 2 unseen_swordsman User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to unseen_swordsman
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

Reply With Quote
  #3  
Old September 12th, 2003, 05:49 PM
mugane mugane is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Charlottesville, VA USA
Posts: 425 mugane User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via AIM to mugane Send a message via Yahoo to mugane
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.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesServer Administration > script probs passing arguments into a loop...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT