The UNIX way.

Around the clock, across the globe. By Vladimir Legeza

Archive for March 2011

Network connection from the shell script.

leave a comment »

Shell allow users to send udp or tcp messages to the remote host and to receive replies  directly from the command line without any additional tools. It seems like a quite useful thing, but the functionality are limited to act only as a tcp/udp client, and not as a server.

The whole following code shows how to exploit this functionality. It should works properly in both major shell interpretors: Bash and Ksh.


exec 3<> /dev/tcp/$host_name/$port_number
echo -e "GET / HTTP/1.0\nHost: $host_name\n\n" >&3
while true ;do
read -r response <&3
echo $response
if [ -z "$response" ];then
Read the rest of this entry »


Written by Vladimir Legeza

March 31, 2011 at 4:23 pm