How do you script ssh commands then background the session? -
i trying create single script starts ssh session, , execute commands on remote machine, backgrounds session. far i've been playing -f or -f -n options, don't know how bring session foreground verify commands executed correctly.
or there way single script can start ssh session , continue inputting commands newly opened session? , background session? if none of work thinking way of doing script starts ssh session, upload , execute commands via script.
any ideas on how this.
it not clear trying do. i'll try helpful.
a series of commands can issued sequentially in single ssh session using single quoted string commands separated semicolons.
$ ssh user@remotehost 'ls; echo foo > bar; cat bar; rm bar'
it return result of last command run.
i'm confused why want background session.
if need can start long running process on remote machine nohup , close session.
if need series of commands run each depend on result of last one, don't need background process, put logic command sequence.
$ ssh user@remotehost 'if ![ -f bar ];then echo foo > bar && cat bar && rm bar; fi'
no harm in multiple sequential ssh , scp connections if there lot of things done.
Comments
Post a Comment