Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Quotes within quotes within quotes nightmare

Status
Not open for further replies.

awingnut

Programmer
Feb 24, 2003
759
US
I am exasperated trying to come up with the correct syntax for this script so I am hoping some fresh eyes will help. I am using 'expect' to issue a command on a remote macine via 'ssh'. The following are the correct command line strings:
Code:
ssh myuser@myhost.mydomain.com
osascript -e 'tell application "QuicKeys"' -e 'play shortcut named "Stop 4D Client"' -e 'end tell'
The following is the script segment is my most recent attempt that doesn't work.
Code:
applescript2="-e 'tell application \\\"QuicKeys\\\"' -e 'play shortcut named \\\"Stop 4D Client\\\"' -e 'end tell'"
   .
   .
   .
expect <<EOF
spawn ssh myuser@myhost.mydomain.com
expect myuser
send "osascript $applescript2"
expect myuser
send "exit"
EOF
I've tried lots of variations of escape and quote sequences but I just cannot get the right combination for the 'send' command so that the 'osascript' command works as it does typing it from the command line.

Can someone suggest the correct syntax to accomplish this? TIA.
 
I had another idea but I can't get it to work. I think I want $applescript2 to ultimately contain \" instead of just ". However, adding another escape literal doesn't do that:
Code:
applescript2="-e 'tell application \\\\\"QuicKeys\\\\\"' -e 'play shortcut named \\\\\"Stop 4D Client\\\\\"' -e 'end tell'"
When 'send' outputs the string it still contains just " rather then \".
 
First of all, can you provide us a little input as to what "spawn" and "expect" are doing?
 
I don't I understand your question. What specifically about 'expect' and 'spawn' do you want to know?
 
Try this...
Code:
applescript2='-e '\''tell application "QuicKeys"'\'' -e '\''play shortcut named "Stop 4D Client"'\'' -e '\''end tell'\'
..or maybe...
Code:
applescript2='-e \'\''tell application \"QuicKeys\"\'\'' -e \'\''play shortcut named \"Stop 4D Client\"\'\'' -e \'\''end tell\'\'
 
Thanks but neither worked. In fact, not using double quotes when setting applescript2 didn't even echo that string in the 'send' command. Only 'osascript' was echoed. On the other hand I was not able to follow all your quote logic at all. :)
 
Dumb, dumb, dumb. :~/

I got. There was no new line character (\n) in the send. Sorry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top