by JoshTriplett · 15y ago · 0 comments
#!/bin/sh
exec ssh "${0##*/}" "$@"
Then create symlinks to ssh-argv0 for common hostnames you ssh to, shortened using host aliases as suggested in the article. You now have a command for each host, which you can use as a prefix like sudo to run a single command on that host. For instance, "myth sudo reboot".If you're used to using "ssh user@box foo", and not always for the same user (in which case you could use "User" in .ssh/config), you can do the same thing via "box -l user foo"
(I feel old...)
Me too.
Here's how to work around it:
#!/bin/sh
exec ssh "$(basename "$0")" "$@"
FWIW it's a little easier to read, too. #!/usr/bin/env sh
So that users who have setup PATH=/usr/xpg4/bin:$PATH get the correct shell and everything works fine.Common idiom, works in POSIX /bin/sh, bash, dash, ash, and every other sh I've encountered. I make a point of avoiding bashisms in /bin/sh scripts, but I have no problem counting on POSIX sh. :)