Dear Lazyweb: single-line way to ssh and run a command?
Dear lazyweb: I want a single-line command that will ssh me into a remote server and run a specified command. I know it's both simple and possible (I did it before and forgot), I want a one-liner that replicates this:
[mel@mylaptop ~]$ ssh mel@remoteserver.org
[mel@remoteserver ~]$ mycommand --option
The closest I've gotten is:
ssh mel@remoteserver.org >> 'mycommand --option'
...which does in fact put 'mycommand --option' on the remote terminal, but won't show it (I'm left staring at my local terminal's screen, but when I ssh into the remote server afterwards, I see 'mycommand --option' in the command history.
Intended usage is to make a zsh alias that will ssh me over to the server I use for irssi + screen, then resume my irssi screen session (screen -raAD).
alias irc=<magic-ssh-command-goes-here>
Oh, and I finally upgraded to GNOME 3 this afternoon. So far, I like it; my dual monitor setup gives me a few UI quirks (as I figure out exactly what these are, I'll document and report them), and I have yet to be able to think "the GNOME 3 way," but it's just very nicely done; my kudos and congratulations go out, very belatedly, to the GNOME team for some excellent and thoughtful work.
UPDATE: Figured it out! It's the -t option for ssh.
The final alias:
alias irc="ssh mel@remoteserver.org -t screen -raAD"