linux - bash 在此 ssh 命令中做了什么?

标签 linux bash shell ssh

ssh -i host 'scripts/myScript start; bash'

start 是 shell 脚本中的一个函数? 在这里将 bash 附加到脚本有什么作用? 一点背景: 它为我生成了一个交互式 shell 并执行 myScript,就像使用普通 ssh 实际登录主机一样。不过,如果我省略了 bash。

ssh -i host 'scripts/myScript start;'

它不会导致交互式登录,而是非交互式 shell 登录,并且由于环境变量问题,我的 myScript 无法按预期工作。

最佳答案

尾随的 bash 将导致在命令 scripts/myScript start 返回后在远程主机上启动 bash 的交互式 session 。

你还需要使用-t分配一个伪终端:

ssh -t host 'scripts/myScript start; bash'

关于linux - bash 在此 ssh 命令中做了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33749470/

相关文章:

c - Ncurses 在后台停止进程

c - 为什么 memcmp() 相差 1 时返回 256?

python - 有没有办法捕获结构输出的 shell 命令的集合?

linux - Bash:如何将类似数组的字符串转换为数组

linux - 一对多合并文件

linux - 搜索多个文件时不要在 zgrep 输出中打印文件名

linux - Linux 上的菜单和子菜单脚本

macos - 我如何在 OSX 的 bash case 语句中失败?

PHP shell_exec 页面超时

正则表达式模式替换