#!/usr/bin/perl use warnings; use strict; use IPC::Open3; # Basic setup stuff open(SAVE_STDOUT,">&",STDOUT) or die "save stdout failed"; open(DEVNULL,"< /dev/null") or die "open /dev/null failed"; # Now set STDOUT to a filehandle on a new descriptor open(FH1,"> /dev/null") or die "open /dev/null failed"; *STDOUT = *FH1; # Run the command open3(*DEVNULL, *PIPE, undef, "/bin/sh","-c",<&2 EOF ; # And copy the output open(STDOUT,">&",*SAVE_STDOUT) or die "restore stout failed"; while () { print "PIPE: ",$_; } close(PIPE) or die "close pipe failed"; exit(0);