Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

(This is a follow-up to my comment on the accepted answermy comment on the accepted answer.)

Note that if $myparameter contains spaces, it will split on the server side. Bash's printf has a %q format that you could use. Example:

$ myparameter='hello; rm somefile' $ ssh user@server "echo $myparameter" hello rm: cannot remove `somefile': No such file or directory $ ssh user@server "echo $(printf '%q' "$myparameter")" hello; rm somefile 

(This is a follow-up to my comment on the accepted answer.)

Note that if $myparameter contains spaces, it will split on the server side. Bash's printf has a %q format that you could use. Example:

$ myparameter='hello; rm somefile' $ ssh user@server "echo $myparameter" hello rm: cannot remove `somefile': No such file or directory $ ssh user@server "echo $(printf '%q' "$myparameter")" hello; rm somefile 

(This is a follow-up to my comment on the accepted answer.)

Note that if $myparameter contains spaces, it will split on the server side. Bash's printf has a %q format that you could use. Example:

$ myparameter='hello; rm somefile' $ ssh user@server "echo $myparameter" hello rm: cannot remove `somefile': No such file or directory $ ssh user@server "echo $(printf '%q' "$myparameter")" hello; rm somefile 
Source Link
janmoesen
  • 2.8k
  • 20
  • 16

(This is a follow-up to my comment on the accepted answer.)

Note that if $myparameter contains spaces, it will split on the server side. Bash's printf has a %q format that you could use. Example:

$ myparameter='hello; rm somefile' $ ssh user@server "echo $myparameter" hello rm: cannot remove `somefile': No such file or directory $ ssh user@server "echo $(printf '%q' "$myparameter")" hello; rm somefile