【问题标题】:Executing more than one command with ssh2 exec使用 ssh2 exec 执行多个命令
【发布时间】:2012-11-16 10:23:43
【问题描述】:

我有一个运行一个命令的脚本。基于该结果,我可以运行下一个命令。步骤:运行第一个脚本,它将我置于全局状态,然后从全局运行下一个命令。
第一个命令:
$stream = ssh2_exec($connection, 'config global');
在这个结果之后我应该运行这个因为我需要进入全局
$stream = ssh2_exec($connection, '获取硬件 cpu');

【问题讨论】:

    标签: ssh command exec


    【解决方案1】:

    你可以这样做

    $stream = ssh2_exec($connection, 'command1;command2');
    

    【讨论】:

    • 只执行第一个:$stream = ssh2_exec($connection, 'config global;get hardware cpu'); stream_set_blocking($stream, true); echo "Output: " . stream_get_contents($stream); fclose($stream);
    猜你喜欢
    • 2014-01-21
    • 2020-07-25
    • 2017-06-19
    • 1970-01-01
    • 1970-01-01
    • 2012-08-18
    • 1970-01-01
    • 2012-05-27
    • 1970-01-01
    相关资源
    最近更新 更多