diff --git a/man/mosh.1 b/man/mosh.1 index 31267cf..496e268 100644 --- a/man/mosh.1 +++ b/man/mosh.1 @@ -21,6 +21,8 @@ mosh \- mobile shell with roaming and intelligent local echo .B mosh .RI [ options ] [user@]host +[--] +[command...] .br .SH DESCRIPTION \fBmosh\fP (mobile shell) is a remote terminal application that @@ -63,6 +65,10 @@ between 60000 and 61000, but allows the user to request a particular UDP port instead. .SH OPTIONS +.TP +.B \fIcommand\fP +Command to run on remote host. By default, \fBmosh\fP executes a login shell. + .TP .B \-\-client=\fIPATH\fP path to client helper on local machine (default: "mosh-client") diff --git a/scripts/mosh b/scripts/mosh index 9a8ad08..d1baaee 100755 --- a/scripts/mosh +++ b/scripts/mosh @@ -37,7 +37,7 @@ my $help = undef; my $version = undef; my $usage = -qq{Usage: $0 [options] [user@]host +qq{Usage: $0 [options] [user@]host [--] [command] --client=PATH mosh client on local machine (default: "mosh-client") --server=PATH mosh server on remote machine @@ -150,11 +150,12 @@ if ( defined $fake_proxy ) { exit; } -if ( scalar @ARGV != 1 ) { +if ( scalar @ARGV < 1 ) { die $usage; } -my $userhost = $ARGV[ 0 ]; +my $userhost = shift; +my @command = @ARGV; # Run SSH and read password my $pty = new IO::Pty; @@ -176,6 +177,10 @@ if ( $pid == 0 ) { # child push @server, ( '-p', $port_request ); } + if ( scalar @command > 0 ) { + push @server, ( '--', @command ); + } + exec 'ssh', '-S', 'none', '-o', "ProxyCommand=$0 --fake-proxy -- %h %p", '-t', $userhost, '--', @server; die "Cannot exec ssh: $!\n"; } else { # server