Reputation: 1111
I need to back up the configuration of a HP ProCurve and I need to do it through SSH.
The ProCurve shell is interactive and I can't put something like:
$ ssh user@ip 'command1; command2'
...because the shell gives me an error — likely because the machine doesn’t actually have a Unix–like shell. I need to connect, input the password, and execute two commands.
Upvotes: 0
Views: 3342
Reputation: 64563
With Procurve/Cisco devices you can not simply run ssh hostname command
. You need to use some tool that can work with interactive ssh sessions, i.e. expect, pexpect or something like this. Another solution is to use socat
:
(sleep 5; echo ${PASSWORD}; sleep 2; echo ; echo command1; sleep 2) \
| socat - EXEC:"ssh ${SWITCH}",setsid,pty,ctty
Upvotes: 3
Reputation: 1110
I'm not sure I entirely understand your question. Are you trying to run multiple commands?
Have you tried sh -c
?
ssh user@ip sh -c "command1; command2"
From 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.
Upvotes: 0