[英]Read HTTP output using shell/bash script
My url (http://myhost.com/getuser/Default.aspx?username= b772643 ) returns the following line of of info always: 我的网址(http://myhost.com/getuser/Default.aspx?username= b772643)返回的总信息的下面一行:
John, Thomas;John.B.Thomas@Company.com
I wish to read this line using a shell or bash script without wget/lynx. 我希望使用没有wget / lynx的shell或bash脚本来阅读这一行。 I'm in a situation where I cannot use any other utility, the perl language etc.
我处于不能使用任何其他实用程序,perl语言等的情况。
Curl or wget are obviously better for the job but for the record bash and Unix standard commands (cat & printf) can do the job. Curl或wget显然对于这项工作更好,但是对于记录bash和Unix标准命令(cat&printf)可以完成这项工作。
ksh introduced shell network internal handling and this has been adopted by bash. ksh引入了shell网络内部处理,这已被bash采用。
#!/bin/bash
exec 5<> /dev/tcp/myhost.com/80
cat <&5 &
printf "GET /getuser/Default.aspx?username=b772643 HTTP/1.0\r\n\r\n" >&5
一个班轮:
(echo 'GET /getuser/Default.aspx?username=b772643' > /dev/tcp/myhost.com/80);
so 所以
curl "http://myhost.com/getuser/Default.aspx?username=b772643"
curl "http://myhost.com/getuser/Default.aspx?username=b772643"| sed 's/\(.*\);\(.*\)/\2 \1/' | while read email name; do echo =$email=$name=; done
You could use : 你可以使用:
curl "http://myhost.com/getuser/Default.aspx?username=b772643"
and extract the datas from what is returned :) 并从返回的内容中提取数据:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.