LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 04-14-2006, 09:38 AM   #1
Thinking
Member
 
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/www.google.com/80
(now we have a connection to google using descriptor 5)
2. create a shell script (google.sh)
#[begin]
echo -e "GET / HTTP/1.0\n" >&5
cat <&5 1>/dev/null
#[end]

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

thx@ll
 
Old 04-15-2006, 12:20 PM   #2
raskin
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: approximately NixOS (http://nixos.org)
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).
 
  


Reply


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 08:21 PM
Bash redirection and subshells nx5000 Programming 2 11-03-2005 06:13 AM
Bash redirection being taken literally by programs R00ts Programming 13 05-26-2005 12:46 AM
bash output redirection: debian vs freebsd kenners Programming 2 10-07-2004 04:56 PM
BASH scripting: confused about redirection & file descriptors funkymunky Programming 1 06-07-2004 07:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:35 AM.

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