I am writing a rpc program, I have put the server program on a directory in another computer and i run the client program from my computer. I want that when i call a function in the server program it will have to execute a shell script and the retruning of the shell script be caught by the server program and sent back to my client to watch or manipulate.
And your question is? Do you need help with C? Sockets? Calling other programs? Capturing their output?
By the way, what's your program supposed to do that SSH can't?
i want to capture the output of a shell program from my C program calling it. Any ideas? I have used popen till now. Is there any other way, because i don't want the output from the shell to be echoed to the servers terminal.
Then you've either got one weird terminal setup (unless I'm mistaken, in which case I'm asking for enlightenment), or your shell script (or a program within) explicitly writes to the terminal, or your program still has some debug printf()'s in it writing to a term.
I couldn't reproduce your problem even with fork()ing and closing all (unneeded) file descriptors (code in attachment)
$ ./process
$ cat output.txt
bin
boot
dev
etc
home
lib
lost+found
media
mnt
opt
proc
root
sbin
srv
sys
tmp
usr
var
var
insgesamt 0
lr-x------ 1 pludi users 64 30. Apr 13:12 0 -> pipe:[1498244]
l-wx------ 1 pludi users 64 30. Apr 13:12 1 -> /tmp/testbed/output.txt
l-wx------ 1 pludi users 64 30. Apr 13:12 1 -> /tmp/testbed/output.txt