Results 1 to 2 of 2
Hi, I have two programs (the standard ftp client and a shell script), which I want to make talk one to each other. I.e. ftp's stdout -> script's stdin AND ...
- 01-14-2009 #1Just Joined!
- Join Date
- Jan 2009
- Posts
- 1
Bash I/O redirection question
Hi, I have two programs (the standard ftp client and a shell script), which I want to make talk one to each other. I.e. ftp's stdout -> script's stdin AND reverse - script's stdout to ftp's stdin ... Is it possible to do this with bash?
I tried pipe + I/O redirection of the stdout of the script to stdin, but it doesn't seem to work.
I tried things like
( exec 5>&0; ( read name; echo "i read $name var" ) | (echo goshko; read b; echo "second script read '$b'") 1>&5 )
The above code just stucks waiting for input ...
Any suggestions ?
- 01-14-2009 #2
Here's what I got:
Having said that, a saner approach to this would probably be to create a named pipe (called a FIFO, see "man 7 fifo"), and then have the output/input redirected appropriately. This will help clean everything up a bit, I expect.Code:alex@danu ~ $ ( exec 5>&0; ( read name; echo "i read $name var" ) | (echo goshko; read b; echo "second script read '$b'") 1>&5 ) goshko *here it waited for input. I typed the following line and pressed enter.* hello second script read 'i read hello var'
DISTRO=Arch
Registered Linux User #388732


Reply With Quote