Can I ssh somewhere, run some commands, and then leave myself a prompt?

前端 未结 5 1416
予麋鹿
予麋鹿 2020-11-29 04:56

I find myself needing to log into various servers, set environment variables, and then work interactively.

e.g.

$ ssh anvil
jla@anvil$ export V=hello         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 05:32

    You could also use the following expect script:

    #!/usr/bin/expect -f
    spawn ssh $argv
    send "export V=hello\n"
    send "export W=world\n"
    send "echo \$V \$W\n"
    interact
    

提交回复
热议问题