B
Bernard Chan
Dear All,
I am pretty new to the area of pipes and IPC in general. I'm currently
experimenting with it in different ways trying to understand how it works.
I tried the following simple command:
$ LANG=C perl -MIPC::Open2 -e 'open2(">&1", "<&0", "ls", "-l",
"/dev/shm")'
total 4
-rw-rw-r-- 1 bernardchan bernardchan 3204 Mar 6 16:00 test.txt
open2: close(0) failed: Bad file descriptor at -e line 1
As you can see, what I would like to do is simple: to run an "ls -l" and
pipe the output directly to STDOUT and have any input (of course none for
this case of "ls") read from STDIN. I can get back the desired output, but
I also receive the error that open2() cannot close the read filehandle.
This is actually a simplified version - my original version used a socket
(IO::Socket::INET6) in place of STDIN and STDOUT. The problem was similar.
Anyone has some insights about what I am doing wrong?
TIA.
Regards,
Bernard Chan.
I am pretty new to the area of pipes and IPC in general. I'm currently
experimenting with it in different ways trying to understand how it works.
I tried the following simple command:
$ LANG=C perl -MIPC::Open2 -e 'open2(">&1", "<&0", "ls", "-l",
"/dev/shm")'
total 4
-rw-rw-r-- 1 bernardchan bernardchan 3204 Mar 6 16:00 test.txt
open2: close(0) failed: Bad file descriptor at -e line 1
As you can see, what I would like to do is simple: to run an "ls -l" and
pipe the output directly to STDOUT and have any input (of course none for
this case of "ls") read from STDIN. I can get back the desired output, but
I also receive the error that open2() cannot close the read filehandle.
This is actually a simplified version - my original version used a socket
(IO::Socket::INET6) in place of STDIN and STDOUT. The problem was similar.
Anyone has some insights about what I am doing wrong?
TIA.
Regards,
Bernard Chan.