我想通过运行./script:
来检查Nortel路由器#!/bin/ksh
print "IP:"
read ip;
ping ${ip};
ssh -l default ${ip} "sho mod; en; sho int; sho node-e; sho node-a";
我可以正常地使用 ssh -l [user] [ip]。
但不是 ssh -l [user] [ip]'[cmd1],[cmd2]'它会自动显示“Conection to [ip] closed。”
答案 0 :(得分:1)
有一个名为expect
的应用程序可以为您进行这种交互/终端模拟。否则,您可以使用fabric
编写脚本,甚至可以使用paramiko
以这种方式运行命令当然会更好,但如果您的路由器不接受这种方式的命令,则需要模拟标准连接。