while using Perl ,I encountered this problem several times and I cannot find the way to solve it.Check the following code
Now if the command who is not found in the path then pipe is not attached to the specified output,but it does not give any error message.
While reading I found the reason is that since die() would be executed upon failure of open() function and in this case open() is not failed ,i.e it successfully opened a pipe but the connection between pipe and the command is failed .
So is there any way to check whether testpipe is actually connected to the given output of command???
PHP:
#!/usr bin/perl -w
$|=1;
print "People connected are :\n";
open(testpipe,"who|") or die("Error : $! ");
while(<testpipe>)
{
print;
}
print "\n\nEnd of list \n\n";
close(testpipe);
While reading I found the reason is that since die() would be executed upon failure of open() function and in this case open() is not failed ,i.e it successfully opened a pipe but the connection between pipe and the command is failed .
So is there any way to check whether testpipe is actually connected to the given output of command???