in reply to Re: pass ARGV to STDIN
in thread pass ARGV to STDIN

Thanks. This is the scenario: I have a server and a client. The client part of the code is what i posted. The client forks with the parent listening , and child sending requests to the server and not the parent. Now the question is reduced to: how do i pass the ARGV[0] (environment) to the child's STDIN . I get that some IPC mechanism to be used. I tried with pipes, no luck. In effect the client should be called with some command-line arg (./client arg) , and not input through STDIN interactively. Any suggestions please.

Replies are listed 'Best First'.
Re^3: pass ARGV to STDIN
by almut (Canon) on Mar 08, 2008 at 08:36 UTC

    Why make things more complicated than they are? If the idea is to send commandline arguments to the server, then just send them (as you would in the parent) and don't read from STDIN — or maybe read from STDIN only if nothing is specified on the commandline, e.g. like this:

    ... #the child process else { unless (@ARGV) { # read a line from stdin, if no args given on command line my $line = <STDIN>; chomp $line; push @ARGV, split(' ', $line); } print $socket "$_\n" for @ARGV; } ...
      Thats smart and works :) Thanks a ton!
Re^3: pass ARGV to STDIN
by alexm (Chaplain) on Mar 08, 2008 at 09:00 UTC
    The client forks with the parent listening , and child sending requests to the server and not the parent.

    Your parent is actually reading from the server, not listening.