hi
any bash-gurus out there?
i want to make a little script like
<script> #!/bin/sh OPTIONS='-send "pd quit"' pd ${OPTIONS} </script>
unfortunately the shell-expansions seems to screw up my mind, and thus i always get the following error: <error> tried /tmp/quit" and failed open: No such file or directory No such file or directory error: "pd: no such object </error>
obviously, the i get the quotes wrong, however, i don't seem to able to get it right.
adding fun, i need double-quotes rather than single-quotes (in order to set the send-message dynamically)
any quick help appreciated
mfg.adsr. IOhannes
IOhannes m zmoelnig wrote:
hi
any bash-gurus out there?
i want to make a little script like
<script> #!/bin/sh OPTIONS='-send "pd quit"' pd ${OPTIONS} </script>
unfortunately the shell-expansions seems to screw up my mind, and thus i
a workaround for my problem seems to be to give the send-message explicitely and in quotes. like: <script> #!/bin/sh OPTIONS="-rt -open ${PATCH}" MSG="pd quit" pd ${OPTIONS} -send "${MSG}" </scrip>
leaving the MSG empty doesn't do anything (which is good).
however, i would like a cleaner solution (where the entire options-string is built dynamically)
mfg.asd.r IOhannes
IOhannes m zmoelnig wrote:
IOhannes m zmoelnig wrote:
hi
any bash-gurus out there?
i want to make a little script like
<script> #!/bin/sh OPTIONS='-send "pd quit"' pd ${OPTIONS} </script>
unfortunately the shell-expansions seems to screw up my mind, and thus i
a workaround for my problem seems to be to give the send-message explicitely and in quotes. like:
<script> #!/bin/sh OPTIONS="-rt -open ${PATCH}" MSG="pd quit" pd ${OPTIONS} -send "${MSG}" </scrip> leaving the MSG empty doesn't do anything (which is good). however, i would like a cleaner solution (where the entire options-string is built dynamically)
Both above scripts work for me, I think the problem lies elsewhere. '' quotes mean literal, so no expansion of variables is done. Quotes inside of quotes are just characters, only the outer most count (AFAIK).
VAR=test
echo '$VAR' prints: $VAR echo "$VAR" prints: test echo '"$VAR"' prints: "$VAR" echo "'$VAR'" prints: 'test'
If that helps at all. You might want to try sticking with only " and escaping the ones inside:
echo ""$VAR"" prints: "test"
.hc
Hans-Christoph Steiner wrote:
Both above scripts work for me, I think the problem lies elsewhere.
which shell are you using? bash? tcsh? something else?? have you tested on linux or osX?
quotes mean literal, so no expansion of variables is done. Quotes inside of quotes are just characters, only the outer most count (AFAIK).
VAR=test
echo '$VAR' prints: $VAR echo "$VAR" prints: test echo '"$VAR"' prints: "$VAR" echo "'$VAR'" prints: 'test'
If that helps at all. You might want to try sticking with only " and escaping the ones inside:
echo ""$VAR"" prints: "test"
unfortunately (since it doesn't help me here), i know all this. the problem -as i see it- is, that my quotes somehow destroy the atomic structure of the enquoted stuff.
e.g. i do: <snip> pd -send "pd quit" </snip> pd now gets 2 args '-send' and 'pd quit'. the '-send' tells pd that the next arg will be a message to shout. the message 'pd quit' is then sent (and received by 'pd')
however, when i do <snip> OPTIONS="-send "pd quit"" pd ${OPTIONS} </snip>
here it seems that pd gets 3(!) args '-send', '"pd' and 'quit"'. pd therefore shouts and empty message to the receiver '"pd' and then tries to open (since it is a non-flagged argument) the patch 'quit"'. of course there is no receiver '"pd' and no patch 'quit"'.
i'm still stupified...
mfg.asdr. IOhannes
On Mar 14, 2006, at 10:53 AM, IOhannes m zmoelnig wrote:
Hans-Christoph Steiner wrote:
Both above scripts work for me, I think the problem lies elsewhere.
which shell are you using? bash? tcsh? something else?? have you tested on linux or osX?
/bin/sh on OSX. But I think that its all the same, that code is so old.
quotes mean literal, so no expansion of variables is done. Quotes inside of quotes are just characters, only the outer most count (AFAIK).
VAR=test
echo '$VAR' prints: $VAR echo "$VAR" prints: test echo '"$VAR"' prints: "$VAR" echo "'$VAR'" prints: 'test'
If that helps at all. You might want to try sticking with only " and escaping the ones inside:
echo ""$VAR"" prints: "test"
unfortunately (since it doesn't help me here), i know all this. the problem -as i see it- is, that my quotes somehow destroy the atomic structure of the enquoted stuff.
e.g. i do:
<snip> pd -send "pd quit" </snip> pd now gets 2 args '-send' and 'pd quit'. the '-send' tells pd that the next arg will be a message to shout. the message 'pd quit' is then sent (and received by 'pd')
however, when i do
<snip> OPTIONS="-send \"pd quit\"" pd ${OPTIONS} </snip>
here it seems that pd gets 3(!) args '-send', '"pd' and 'quit"'. pd therefore shouts and empty message to the receiver '"pd' and then tries to open (since it is a non-flagged argument) the patch 'quit"'. of course there is no receiver '"pd' and no patch 'quit"'.
i'm still stupified...
can you post the actual script? Its hard to tell what's happening based on the snippets.
.hc
________________________________________________________________________ ____
¡El pueblo unido jamás será vencido!