Skip to content

Instantly share code, notes, and snippets.

@amaslenn
Created September 22, 2016 14:05
Show Gist options
  • Save amaslenn/06fdaf68b5cfe9f047af7bcff82af579 to your computer and use it in GitHub Desktop.
Save amaslenn/06fdaf68b5cfe9f047af7bcff82af579 to your computer and use it in GitHub Desktop.
# run external cmd and dump its output in ~realtime
sub run_or_die {
my $cmd = shift;
local $| = 1;
say "[cmd]: $cmd";
open my $hp, "$cmd |" or die "$!\n";
while (<$hp>) {
s/\r|\n//g;
say;
}
close $hp;
die "[$?] $!\n" if $? >> 8;
say '';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment