27 Sep 2011 21:40
Re: Network redirection in bash
2011-04-10, 04:26(-07), Todd A. Jacobs: > I'm trying something a little weird, and am not having much success > with my shell redirection to a network port. I'm trying to send an MS > Word file to antiword running out of inetd. Here's what I have on the > client side: > > exec 4<> /dev/tcp/127.0.0.1/2100 > cat /tmp/foo.doc >&4 > cat <&4 > > This seems like it should work, but I never get any results back from > antiword. Basically, it just waits until the service times out. > > I'm hoping I'm just doing something wrong with my shell redirection > here. Thoughts? It won't work for the same reason as cat foo.doc /dev/tty | antiword - won't output anything until you press Ctrl-D. You'd need to shutdown the socket for sending first so that antiword sees the end of file. Unfortunately, I don't think bash allows you do close the sending and receiving side separately. zsh's ztcp can't either as far as I can tell. You'd need to find a way to tell antiword about the end of input another way. You could for instance change it to accept uuencoded files and handle the input with a wrapper script that does:(Continue reading)
RSS Feed