Shell 在ProCurve上使用SSH链接命令

Shell 在ProCurve上使用SSH链接命令,shell,ssh,interactive,Shell,Ssh,Interactive,我需要备份HP ProCurve的配置,并且需要通过SSH进行备份 ProCurve shell是交互式的,我不能放置以下内容: $ ssh user@ip 'command1; command2' …因为shell给了我一个错误-可能是因为机器实际上没有类似Unix的shell。我需要连接、输入密码并执行两个命令。我不确定我是否完全理解您的问题。您正在尝试运行多个命令吗? 你试过sh-c吗 ssh user@ip sh -c "command1; command2" 从man sh:

我需要备份HP ProCurve的配置,并且需要通过SSH进行备份

ProCurve shell是交互式的,我不能放置以下内容:

$ ssh user@ip 'command1; command2'

…因为shell给了我一个错误-可能是因为机器实际上没有类似Unix的shell。我需要连接、输入密码并执行两个命令。

我不确定我是否完全理解您的问题。您正在尝试运行多个命令吗? 你试过sh-c吗

ssh user@ip sh -c "command1; command2"
man sh

       -c               Read commands from the command_string operand instead of from the standard input.  Special parameter 0 will be set from the command_name operand
                        and the positional parameters ($1, $2, etc.)  set from the remaining argument operands.

我不确定我是否完全理解你的问题。您正在尝试运行多个命令吗? 你试过sh-c吗

ssh user@ip sh -c "command1; command2"
man sh

       -c               Read commands from the command_string operand instead of from the standard input.  Special parameter 0 will be set from the command_name operand
                        and the positional parameters ($1, $2, etc.)  set from the remaining argument operands.

使用Procurve/Cisco设备,您不能简单地运行
ssh hostname命令
。您需要使用一些能够处理交互式ssh会话的工具,例如expect、pexpect或类似的工具。另一种解决方案是使用
socat

(sleep 5; echo ${PASSWORD}; sleep 2; echo ; echo command1; sleep 2) \
| socat - EXEC:"ssh ${SWITCH}",setsid,pty,ctty

使用Procurve/Cisco设备,您不能简单地运行
ssh hostname命令
。您需要使用一些能够处理交互式ssh会话的工具,例如expect、pexpect或类似的工具。另一种解决方案是使用
socat

(sleep 5; echo ${PASSWORD}; sleep 2; echo ; echo command1; sleep 2) \
| socat - EXEC:"ssh ${SWITCH}",setsid,pty,ctty