替代猫了一个bash脚本的? [英] Alternative to Cat out of a bash script?

查看:133
本文介绍了替代猫了一个bash脚本的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的问题。

exec 3<>/dev/tcp/$1/37491

echo -ne 060e2b3 00$hexdec$cmdhex | perl -pe 's/([0-9a-f]{2})/chr hex $1/gie' >&3

cat <&3

我有我一个十六进制字符串发送到与所取得的端口/ tcp连接的服务器。但由于我通过一个终端使用腻子我的第一个问题是,XML响应返回总是说腻子和它不逃避。我也需要把后面的答复有时在数组中,我曾尝试

i have a server in which i send a hex string to with the port / tcp connection made. BUT since i am using putty through a terminal my first issue is that the XML response back always says PuTTY and it doesnt escape. I also need to put the replies back sometimes in an array and i have tried

array=`cat <&3`

echo "Array items:"
for item in ${array[*]}
do
    printf "   %s\n" $item
done

和我相信,因为猫不正确退出它只是保持打开阵列不这样做?

and i believe since the cat is not exiting properly it just stays open the array is not done?

感谢先进的帮助

推荐答案

你需要指定一个超时?

while read -t 5 line <&3; do 
    echo "$line"
    (( Lines++ ))
done
exec 3>&-

这篇关于替代猫了一个bash脚本的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆