Can't pipe echo to netcat?
Posted
by
user1641300
on Server Fault
See other posts from Server Fault
or by user1641300
Published on 2014-08-21T20:32:03Z
Indexed on
2014/08/21
22:21 UTC
Read the original article
Hit count: 230
I have the following command:
echo 'HTTP/1.1 200 OK\r\n' | nc -l -p 8000 -c
and when I curl localhost:8000
I am not seeing HTTP/1.1 200 .. being printed.
I am on mac os x with netcat 0.7.1
Any ideas?
#!/bin/bash
trap 'my_exit; exit' SIGINT SIGQUIT
my_exit()
{
echo "you hit Ctrl-C/Ctrl-\, now exiting.."
# cleanup commands here if any
}
if test $# -eq 0 ; then
echo "Usage: $0 PORT"
echo ""
exit 1
fi
while true
do
echo "HTTP/1.1 200 OK\r\n" | nc -l -p ${1} -c
done
and testing with:
curl localhost:8000
© Server Fault or respective owner