Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 04-14-2006, 10:38 AM   #1
Registered: Oct 2003
Posts: 249

Rep: Reputation: 30
bash: socket redirection?

for my problem i give a little example:

1. execute this:
exec 5<>/dev/tcp/
(now we have a connection to google using descriptor 5)
2. create a shell script (
echo -e "GET / HTTP/1.0\n" >&5
cat <&5 1>/dev/null

the script sends a get request using descriptor 5 (e.g. to google)
and retrieves the result (since i don't need everything on stdout i redirect it to /dev/null)
3. execute the shell script

what i need is transparent logging
this means, everything which is sent or received (in this example using descriptor 5) should be logged to a file (or two files, ingoing, outgoing)
i thought about using tee to redirect 5 to stdin/stdout or something
but i have no idea how to do this

any suggestion would be great

Old 04-15-2006, 01:20 PM   #2
Senior Member
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (
Posts: 1,900

Rep: Reputation: 69
First supposition: make a fifo (with mkfifo) and run tee with output to log and to fifo (with input from socket). Then read the fifo instead. Reverse on output (try to log input first, not to spare efforts twice if I'm wrong).


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH scripting I/O redirection error blinux1 Programming 13 03-18-2008 09:21 PM
Bash redirection and subshells nx5000 Programming 2 11-03-2005 07:13 AM
Bash redirection being taken literally by programs R00ts Programming 13 05-26-2005 01:46 AM
bash output redirection: debian vs freebsd kenners Programming 2 10-07-2004 05:56 PM
BASH scripting: confused about redirection & file descriptors funkymunky Programming 1 06-07-2004 08:47 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:31 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration