My url (http://myhost.com/getuser/Default.aspx?username=b772643) returns the following line of of info always:
John, Thomas;[email protected]
I wish to read this line using a shell or bash script without wget/lynx. I'm in a situation where I cannot use any other utility, the perl language etc.
Curl or wget are obviously better for the job but for the record bash and Unix standard commands (cat & printf) can do the job.
ksh introduced shell network internal handling and this has been adopted by 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
One liner:
(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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With