Support command in mosh wrapper script
This commit is contained in:
@@ -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")
|
||||
|
||||
+8
-3
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user