【问题标题】:Need to run remote script on remote machine from local machine Unix需要从本地机器 Unix 在远程机器上运行远程脚本
【发布时间】:2016-04-02 01:01:09
【问题描述】:

我想运行一个脚本 test.sh,它位于 A 本身的机器 A 上,但来自机器 B。在 Unix 中有什么方法可以做到这一点

【问题讨论】:

    标签: linux shell unix sh remote-server


    【解决方案1】:

    您可以使用ssh 来实现:

    ssh -t user@host '/path/to/test.sh'
    

    根据man ssh,这就是-t 选项的作用:

    强制伪 tty 分配。这可用于在远程机器上执行任意基于屏幕的程序,这很有用, 例如实现菜单服务时。多个 -t 强制 tty 分配,即使 ssh 没有本地 tty。

    【讨论】:

    • -t 是干什么用的?我尝试了以下命令 ssh user@host '/path/to/script' 但它采用本地路径并查找本地脚本。
    猜你喜欢
    • 1970-01-01
    • 2014-04-14
    • 1970-01-01
    • 1970-01-01
    • 2012-09-26
    • 2018-07-18
    • 2011-06-30
    • 2013-08-16
    • 1970-01-01
    相关资源
    最近更新 更多