1

I have small client program that uses rsh to get the inode number for a file. The problem I face is the rsh command is getting executed but there is no output is read by the parent.

If I run any command lets say "ls" that is executed locally, I can see the output.

/* Child */

close pipe[0];

dup2(pipe[1],STDOUT_FILENO);

execv("/usr/bin/rsh","ls","-i","a.txt");

/* Parent */

close pipe[1]

bytes  = read pipe[0]

/* bytes always is 0. But if I have ls executed by child, 
 * I can see full output */
tjd
  • 4,064
  • 1
  • 24
  • 34

1 Answers1

0

Any takers?

I think I have the reason why there is no output seen by parent.

As I understand, "rsh" needs a tty terminal and running in foreground to be able to put its output.

When I run rsh in background on a shell, I can see that there is no output.

root@vmx2_p2_re1% rsh -n -T re0 ls & [9] 97216 root@vmx2_p2_re1% [9] Done rsh -n -T re0 ls root@vmx2_p2_re1%

When I run in foreground I can see the output:

root@vmx2_p2_re1% rsh -T re0 ls .cshrc .history .login .profile junos.base.conf

When I try a normal command and have it run in background, I can see the output on the terminal.

root@vmx2_p2_re1% ls & [9] 97297 root@vmx2_p2_re1% 1 a.txt dfwc.out filter-define.conf filter-define.conf.bk

[9] Done ls

Does anyone have an idea on how to get the output of rsh when its not invoked from a shell but from a daemon OR is invoked in the background?

Thanks a lot!