LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Redirecting sh output to a pipe (https://www.linuxquestions.org/questions/programming-9/redirecting-sh-output-to-a-pipe-443542/)

elmafiacs 05-10-2006 01:55 PM

Redirecting sh output to a pipe
 
I want to redirect the output of a 'sh' shell to a socket, from a C program. I have a big problem: nothing appears!. I mean, when I redirect the output of, for example, a 'ls' command, it works just fine; but when I try it with 'sh' it doesn't.

I thought this was because 'sh' also opens STDIN at start, and that may be screwing pipes up. So I closed them ( close(0); ), but it still didn't work.

Can someone point out why I can get things right?


All times are GMT -5. The time now is 05:19 AM.