![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Remove double quotes | deepakwins | UNIX for Dummies Questions & Answers | 3 | 05-30-2008 11:53 AM |
| Double quotes or single quotes when using ssh? | password636 | Shell Programming and Scripting | 3 | 05-29-2008 08:52 PM |
| incorrect quotes/escaping? | new2ss | Shell Programming and Scripting | 2 | 09-02-2007 10:39 PM |
| Supress ' quotes in a select statement inside Shell Script | mahabunta | Shell Programming and Scripting | 1 | 12-14-2006 06:29 PM |
| How do I insert double quotes | dsean | Shell Programming and Scripting | 3 | 05-26-2006 01:28 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
escaping double-quotes inside the script?
I'm having a strange problem with escaping double-quotes. I have a script that looks like this:
Code:
#!/bin/bash
[snip]
for HOST in `cat $INFILE | grep -v ^#`
do
for VFILER in `some_command`
do
echo " "
echo -e '\E[32;40m' " **************** VFiler $VFILER on $HOST ***************"; tput sgr0
ssh $HOST "vfiler run $VFILER "$COMMAND""
echo " "
echo " "
done
done
Code:
ssh nas01a "vfiler run fs03n cifs shares -change * -novscanread" Code:
ssh nas01a vfiler run fs03n cifs shares -change * -novscanread Code:
ssh $HOST \""vfiler run $VFILER "$COMMAND""\" |
|
||||
|
Thanks! eval definitely helped, this works:
Code:
eval ssh $HOST \"vfiler run $VFILER "$COMMAND"\" I tried escaping backslashes inside double quotes as you suggested - still no go. Thankfully eval does the trick! |
|
||||
|
Quote:
Here is what happens to your command: 1. The shell interprets it, thus removing the unescaped quotes from the string and applying them on the string. In the same step the variables are expanded (textually replaced by their value). 2. The interpreted string is then split up into the command intself (ssh) and its options and/or parameters ($HOST ...) 3. Only now ssh itself starts its work - it opens up a connection to the remote host and feeds it what it was given as command line. 4. The shell on the remote host executes *its* command line, more or less starting over from 1. What do we learn from that? We want to preserve the quotes from being interpreted by the first shell, so we have to make them look like ordinary characters withot special meaning to it - this is what "escaping" means. Hence we have to put the double quotes *inside* the string, not outside: Code:
ssh $HOST "\"some command\"" Code:
<ssh> <hostname> <"some command"> I hope this helps. bakunin |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|