Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 可以在telnet上运行的shell上运行bash命令吗?_Linux_Bash_Telnet - Fatal编程技术网

Linux 可以在telnet上运行的shell上运行bash命令吗?

Linux 可以在telnet上运行的shell上运行bash命令吗?,linux,bash,telnet,Linux,Bash,Telnet,因此,我们有运行Linux的嵌入式Linux板。 我们可以使用telnet连接到该板,这会生成shell并允许访问它 现在我正在编写一个bash脚本,希望在该shell上运行命令并获得其输出 e、 我的命令类似于下面的telnet命令,看看这是否成功 test -c /dev/null 当我像下面那样运行它时,我总是将1作为退出状态 { test -c /dev/null; sleep 1;} | telnet <board ip addr> {test-c/dev/null;s

因此,我们有运行Linux的嵌入式Linux板。
我们可以使用telnet连接到该板,这会生成shell并允许访问它

现在我正在编写一个bash脚本,希望在该shell上运行命令并获得其输出

e、 我的命令类似于下面的telnet命令,看看这是否成功

test -c /dev/null
当我像下面那样运行它时,我总是将
1
作为退出状态

{ test -c /dev/null; sleep 1;} | telnet <board ip addr>
{test-c/dev/null;sleep 1;}telnet
如果可能的话我不想用expect


有什么建议/建议吗

使用SSH可以轻松而稳健地完成以下工作:

ssh yourhost 'test -c /dev/null'
在TCP端口上使用一个简单的shell,您可以使用以下功能:

echo 'test -c /dev/null; echo $?' | nc -q 1 yourhost 1234
telnet
是出了名的时间敏感和脚本技巧,因此,由于您不想使用
expect
来实现这一点,您可以尝试对其进行模糊处理:

{ sleep 1; echo 'test -c /dev/null; echo $?'; sleep 1; } | telnet somehost

您可以在该Linux板上安装ssh服务器吗?不可以安装ssh:(