-
-
Save yath/fa9267b7d399223fc77c to your computer and use it in GitHub Desktop.
sssh - sane(r) ssh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# sssh - sane(r) ssh | |
# | |
# executes a remote command (more) sanely by passing the arguments url-like | |
# escaped (foo%23bar for "foo#bar") and unpacking them on the remote side | |
# with perl again. | |
if [ "$#" -lt 2 ]; then | |
echo "Usage: $0 <host> <command> [arguments...]" >&2 | |
exit 1 | |
fi | |
host="$1"; shift | |
exec ssh "$host" "perl -le 's/%(..)/chr hex \$1/ge for @ARGV; exec { \$ARGV[0] } @ARGV or die \$!.\$/' --" \ | |
$(perl -le 'for (@ARGV) { s/[^A-Za-z0-9,.-]/sprintf("%%%02x", ord $&)/ge; print }' -- "$@") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment