Skip to content

Instantly share code, notes, and snippets.

@Cside
Created October 10, 2012 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cside/3862937 to your computer and use it in GitHub Desktop.
Save Cside/3862937 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
# Usage:
# $ perl fork.pl 'ssh XXX@XXXX "some_heavy_command"'
use strict;
use warnings;
use Capture::Tiny;
my $cmd = shift || die 'no command.';
my $pid = fork;
if (defined $pid && $pid == 0) {
my $out = Capture::Tiny::capture_merged {
system $cmd;
};
print <<"...";
# ====================================
# $cmd
# ====================================
$out
...
exit 1;
} elsif (! defined $pid) {
die "couldn't not fork";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment