#!/usr/bin/perl use warnings; use strict; use IPC::Open3; $|=1; #my $pid=open3(\*IN,\*OUT,\*ERR,'/bin/bash'); my $pid=open3(\*IN,\*OUT,0,'/bin/bash'); # set \*ERR to 0 to send STDERR to STDOUT my $cmd = 'ls -la'; #send cmd to bash print IN "$cmd\n"; #getresult while() { print; if(eof(OUT)) { goto GOLAST; } } GOLAST: close IN; close OUT;