bash - Exit from an SSH session but not script -
in bash script, do:
ssh me9@some_mad_server.com; cd ~/apple; echo "before exit" exit echo "after exit" i never see before exit or after exit. can understand why may not see before exist script @ stage in console. confused if exit mean script ends , hence why after exit never gets logged.
any appreciated.
to execute series of commands on remote host, need pass them ssh on command line, not execute them after ssh call. this:
ssh me9@some_mad_server.com ' cd ~/apple echo "before exit" ' echo "after exit" this uses multiline string pass multiple commands. exit implicit when end of string reached.
importantly, commands in quoted string executed on remote host, while final echo executed on local server. i've indented remote commands clarity.
Comments
Post a Comment