Skip to content

Instantly share code, notes, and snippets.

@leihog
Created August 30, 2016 12:35
Show Gist options
  • Save leihog/8ea31cde841e7049ea7d49ab3e88835b to your computer and use it in GitHub Desktop.
Save leihog/8ea31cde841e7049ea7d49ab3e88835b to your computer and use it in GitHub Desktop.
run-local-script-remote
#!/bin/sh
cmd=${0##*/}
ssh -t $1 "$(sed '1,/^#xxxREMOTExxx#$/d' < $0) > /tmp/$cmd.$$.sh && sh /tmp/$cmd.$$.sh; rm /tmp/$cmd.$$.sh"
exit $?
#xxxREMOTExxx#
#!/bin/sh
echo "This is executed on the remote server"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment