Leser: 1
6 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
11
my $cmd = "dir";
my $output = `$cmd 2>&1`;
if ($? != 0)
{
print "stderr: '$output'\n";
}
else
{
print "stdout: '$output'\n";
}
foo > foo.stdout 2> foo.stderr
1
2
3
4
5
6
7
8
9
10
11
12
13
You can check all the failure possibilities by inspecting $?
like this:
if ($? == -1) {
print "failed to execute: $!\n";
}
elsif ($? & 127) {
printf "child died with signal %d, %s coredump\n",
($? & 127), ($? & 128) ? 'with' : 'without';
}
else {
printf "child exited with value %d\n", $? >> 8;
}
6 Einträge, 1 Seite |