passing asterisk to a script as variable


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting passing asterisk to a script as variable
# 8  
Old 04-01-2008
You could parse the command line parameters inside the script.

cat test-script
Code:
#!/bin/sh

COMMAND=$(echo "$@" | sed 's/\\//')

for HOST in `cat $INFILE | grep -v ^#`
do
   echo "============== $HOST ==============="
   echo " "
   ssh $HOST $COMMAND
   echo " "
   echo " "
done

Code:
test-script "some_command \* options"

# 9  
Old 04-01-2008
Quote:
Originally Posted by cfajohnson

Always quote your variables (unless you have a good reason not to):
Code:
ssh "$HOST" "$COMMAND"

That was it, this was the source of the problem! Thanks for pointing it out! Smilie

Last edited by GKnight; 04-02-2008 at 11:27 AM.. Reason: figured it out...
# 10  
Old 04-02-2008
Thanks again for the help, it works fine now that I quote the variable inside the script Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing variable from called script to the caller script

Hi all, Warm regards! I am in a difficult situation here. I have been trying to create a shell script which calls another shell script inside. Here is a simplified version of the same. Calling Script. #!/bin/ksh # want to run as a different process... (6 Replies)
Discussion started by: LoneRanger
6 Replies

2. Shell Programming and Scripting

Need to use asterisk in variable

Hi All, I am having a challange to pass the asterisk in the variable. Basically, I am writing a shell script to check if a marker file exists but when I am assigning the varialbe it cannot use the wildcard asterisk as expected, therefore, my program is always outputs "Marker file is not... (4 Replies)
Discussion started by: express14
4 Replies

3. Shell Programming and Scripting

Passing variable as an argument to another script

Hi, I am trying to pass a variable as an argument to another script. While substitution of variable, I am facing a problem. varaiable "a" value should be -b "FPT MAIN". When we pass "a" to another script, we are expecing it to get substitue as ./test.sh -b "FPT MAIN". But, it is getting... (9 Replies)
Discussion started by: Manasa Pradeep
9 Replies

4. Shell Programming and Scripting

help passing variable from script

Hello, How can I pass a variable into a 2nd file? I'm running a script: ls -la $1 >pem99 cat pem99 | awk '{ print $3}' >us99 cat us99 | read us98 This then tells me the owner of a file. my second file is: echo OWNER GROUP OTHERS echo echo --data-- $us98 ... (2 Replies)
Discussion started by: Grueben
2 Replies

5. Shell Programming and Scripting

Passing variable from shell script to python script

I have a shell script main.sh which inturn call the python script ofdm.py, I want to pass two variables from shell script to python script for its execution. How do i achieve this ????? Eg: main.sh a=3 b=3; c= a+b exec python ofdm.py ofdm.py d=c+a Thanks in Anticipation (4 Replies)
Discussion started by: shashi792
4 Replies

6. Shell Programming and Scripting

How to assign * asterisk to variable?

How can I assign asterisk to variable I have try a="\* " but I was not succesful :( any idea ? thanks (5 Replies)
Discussion started by: kvok
5 Replies

7. Shell Programming and Scripting

Passing asterisk As A Parameter

I have written a Shell Script Program which accepts 3 parameters as shown below: ./calc 20 + 2 in the above line ./calc is the Shell Script itself with 3 parameters, namely: 20 + and 2. Well, now let's look inside the Script: result=$1$2$3 echo $result The output will be as... (8 Replies)
Discussion started by: indiansoil
8 Replies

8. Shell Programming and Scripting

How to ignore * (asterisk) in a variable

I am using a shell script to read SQL statements stored in a DB2 table and write them out to a file. The problem I have is that some SQL statements have an "*" in them which gets resolved as the list of files in the current directory when I run the script. How can I prevent the "*" from being... (7 Replies)
Discussion started by: bradtri2
7 Replies

9. UNIX for Dummies Questions & Answers

passing variable to my script

Hello everybody: Im trying to run the following script on my sol9 machine: line='' ((lineCount= 0)) export lineCount more /tmp/MSISDNs | wc -l > /tmp/tmp cat /tmp/tmp | read lineCount export lineCount; while (( lineCount > 0 )) do line= tail -$lineCount... (5 Replies)
Discussion started by: aladdin
5 Replies

10. UNIX for Advanced & Expert Users

Passing a variable into an awk script

Hello all, I'm trying to run a script of this format - for i in $(cat <file>); do grep $i <file1>|awk '{print $i, $1, $2}' It's not working - does anyone know how this can be done? Khoom (5 Replies)
Discussion started by: Khoomfire
5 Replies
Login or Register to Ask a Question