PDA

View Full Version : A confusing problem



gordonyb0
June 6th, 2006, 09:25 AM
Wow,Here i have a question
I use execl() to display the result of "ps -l",but i don't want it to be shown in the stdout but in a file call "temp" instead.
i try to write like execl("/bin/ps","ps","-l",">","$HOME/temp",(char *)0);
It doesn't work.
so,is there any other function which can solve my problem? Pls tell me.:confused:

LordHunter317
June 6th, 2006, 03:19 PM
Adjust the stdout file descriptor (FD 1) to point to the file temp before you make the execl() call.

thumper
June 6th, 2006, 04:52 PM
It depends on the language, but there are normally other commands that instead of writing to stdout, stderr give you access to the file handles.
You cand then do what ever you want with the output.