shell脚本:向串行控制台发送命令并获取结果

shell脚本:向串行控制台发送命令并获取结果,shell,serial-port,freebsd,bsd,Shell,Serial Port,Freebsd,Bsd,在我的计算机上有一个连接到串行接口的Cisco WS-C3550,我可以使用以下命令连接到设备: cu -l /dev/cuau0 -s 9600 如果我连接到设备,我将发送以下命令 show interface FastEthernet0/2 我想在shell脚本中使用这个命令的输出来获取一些值,我该怎么做呢?我使用FreeBSD(pfsense 2.0.1)作为操作系统 我想试试这样的东西 echo 'show interface FastEthernet0/2' > cu -l

在我的计算机上有一个连接到串行接口的Cisco WS-C3550,我可以使用以下命令连接到设备:

cu -l /dev/cuau0 -s 9600
如果我连接到设备,我将发送以下命令

show interface FastEthernet0/2
我想在shell脚本中使用这个命令的输出来获取一些值,我该怎么做呢?我使用FreeBSD(pfsense 2.0.1)作为操作系统

我想试试这样的东西

echo 'show interface FastEthernet0/2' > cu -l /dev/cuau0 -s 9600 > test.log
但这不起作用。我发现以下错误:

输出重定向不明确

尝试:


~。
断开连接请参见

可能是echo'show interface fasteEthernet0/2'| cu-l/dev/cuau0-s 9600>test.log是的,它可以工作,但现在我无法退出此控制台,当我插入此命令时,将显示一个命令提示符。如果我在cu终端,我不能在新线路上以“~”退出。可以给cu command多个命令吗?谢谢你的回答,但这不起作用,我会在运行该命令后得到提示,test.log的内容是“已连接”的,请参见上面的注释。如果我在提示符下输入此命令,则会在新行中出现一个命令提示符,并且test.log文件中有以下内容:“Connected”仅此而已
echo -e 'show interface FastEthernet0/2\n~.' | cu -l /dev/cuau0 -s 9600 > test.log