Run a local script on a remote server using ssh with out having to worry about quotes

Posted by Michael Irey on Server Fault See other posts from Server Fault or by Michael Irey
Published on 2013-06-28T16:02:23Z Indexed on 2013/06/28 16:24 UTC
Read the original article Hit count: 231

Filed under:
|

So I have been running local scripts fine on a remote server:

ssh user@server '`cat local-script.sh`'

However, today I have a script that has both single and double quotes in it. Which causes the script to fail because the output of cat local-script.sh is wrapped in quotes. With out modifying the script itself, is there a better way to handle this?

I thought this may work:

ssh user@server $(<local-script.sh)

But is does not seem to do anything...

© Server Fault or respective owner

Related posts about ssh

Related posts about bash