"rm $0" in expect
I want to insert rm $0 in a script (/home/user/config-script) located on remote server with echo "rm $0" >> /home/user/config-script with expect. But fail because expect interprets $0 .
Code:
var1="rm \$0" |
I think it is bash that interprets the $0, try single-quoting the var1 and skip the same in the expect command. (have never used expect, so...)
Code:
var1='rm $0' |
Actually, these two lines should work the same.
Code:
var1="rm \$0" Now I'm not familiar with expect either, but in any case when you have a long string of commands to pass to an external program, it usually pays to store them in a separate variable first. It also helps readability to separate each command out in a separate line. Code:
var1='rm $0' Code:
'... Code:
... It took me a bit of trying to get it right, but all you really need to do is ensure that expect gets the values properly backslashed: Code:
var1='rm \$0' BTW, do you really need the extra $var1 step in the first place? Can you not just hard-code it in with the rest of the commands? Code:
send "echo \"rm \$0\" >>/home/user/config-script\n" ; |
Quote:
For me only works with: Code:
var1='rm \\\$0' Code:
send "echo '"'rm \\\$0'"' >>/home/user/config-script\n" ; |
All times are GMT -5. The time now is 02:23 PM. |