Skip to content

Instantly share code, notes, and snippets.

@goozbach
Created April 22, 2009 21:11
Show Gist options
  • Save goozbach/100079 to your computer and use it in GitHub Desktop.
Save goozbach/100079 to your computer and use it in GitHub Desktop.
sub run_command {
my $self = shift();
my $cmdname = shift();
my $dir = tempdir();
INFO("running commmand \`$cmdname\':\t");
my $cmd = system("$cmdname 1>$dir/out.txt 2>$dir/err.txt");
my $output = slurp("$dir/out.txt");
my $error = slurp("$dir/err.txt");
if ($cmd == 0) {
INFO("SUCESS");
DEBUG("OUTPUT:\n$output" . "END_OF_OUTPUT");
} else {
ERROR("ERROR in command \`$cmdname\'". ":\n$error". "END_OF_ERROR");
}
return $cmd;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment