Support command in mosh wrapper script

This commit is contained in:
Keith Winstein
2012-03-18 03:40:49 -04:00
parent 235fc6b559
commit aaeb1ccfbc
2 changed files with 14 additions and 3 deletions
+8 -3
View File
@@ -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