Here is this line in perl:
open my $fh_echo, '-|' or exec "$sshstr \"$str\"";
Basically it exec’s $sshstr and then the output goes into $fh_echo, somehow. I am curious as to the mechanisms that go behind this operation. Can someone explain what the ‘-|’ means?
Also how does this loads the output into $fh_echo? Does it output it little by little or is $fh_echo simply a handle to the output of exec?
Haha I can’t even google this cuz -| don’t show up in the results.
See perlfork. That’s a forking pipe open.
Basically,
|-pipes output to a forked child process, and-|reads (within the child process) from the parent.From perldoc -f open:
In your example, you’re opening a pipe to read from a child process, then forking, then in the child, replacing the process with
$sshstr.