# see qx/STRING/ in perlop, $? in perlvar, perlvar#error indicators my( @output, $status ); ($status, @output) = do_this_cmd( 'net use' ); ($status, @output) = do_this_cmd( 'net arf' ); ($status, @output) = do_this_cmd( 'netz arf' ); sub do_this_cmd { my $the_cmd = shift; my( @the_output, $error_status ); @the_output = qx($the_cmd 2>&1); $error_status = $? / 256; # Peek at arguments and returned values while debugging if(1){ printf "\nExecuted command '%s'\n", $the_cmd; printf "Process returned error status '%d'\n", $error_status if $error_status; if( @the_output ) { foreach (@the_output) { print " >>> ", $_; } } else { print "Process didn't return any output!\n"; } } ( $error_status, @the_output ); }