Mosh: Mosh drops connection when command has dash - symbol

Created on 28 Aug 2015  路  6Comments  路  Source: mobile-shell/mosh

Running mosh on OS X installed with brew install mosh

mosh server_alias screen - works
mosh server_alias 'screen -dR session_name' - [mosh is exiting.]

mosh server_alias and screen -dR session_name' - works

any hint's how to debug that?

Most helpful comment

ssh's command-line parsing is buggy and we chose not to emulate it. The arguments to mosh are exactly the same as a normal shell. If you run 'tmux a -t pairing || tmux new -s pairing' at the shell, you'll get "command not found," and the same happens with mosh. (Run mosh with --no-init to see the error message.) But you can run this to do what you're trying to do:

mosh server_alias -- sh -c 'tmux a -t pairing || tmux new -s pairing'

All 6 comments

Mosh follows the convention of using -- as a separator to end parsing of options.

Try this: mosh server_alias -- screen -dR session_name

Ok, probably I brough wrong example I have a

mosh server_alias -- 'tmux a -t pairing || tmux new -s pairing'

it works when session is established and first command pick up session,
but when I'm expecitng to get non zero exit code and try the second command it extitng.

with ssh i run that as ssh server_alias -t 'tmux a -t pairing || tmux new -s pairing'

ssh's command-line parsing is buggy and we chose not to emulate it. The arguments to mosh are exactly the same as a normal shell. If you run 'tmux a -t pairing || tmux new -s pairing' at the shell, you'll get "command not found," and the same happens with mosh. (Run mosh with --no-init to see the error message.) But you can run this to do what you're trying to do:

mosh server_alias -- sh -c 'tmux a -t pairing || tmux new -s pairing'

To elaborate a bit on how mosh works the same as sh (and unlike ssh):

$ echo "Hell's kitchen"
Hell's kitchen
$ mosh --no-init localhost -- echo "Hell's kitchen"
Hell's kitchen

[mosh is exiting.]
$ ssh localhost -- echo "Hell's kitchen"
bash: -c: line 0: unexpected EOF while looking for matching `''
bash: -c: line 1: syntax error: unexpected end of file

Awesome! Thanks for detailed explanation.
Created https://github.com/mobile-shell/mosh/wiki/Usage where we can move this beautiful example.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xironix picture xironix  路  8Comments

cshei picture cshei  路  5Comments

brandonkal picture brandonkal  路  7Comments

Shoozza picture Shoozza  路  7Comments

franzf picture franzf  路  5Comments