-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexec.pl
52 lines (47 loc) · 1.03 KB
/
exec.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright 2012 - 2013, Steve Rader
# Copyright 2013 - 2014, Scott Kostyshak
sub task_exec {
my ($cmd) = @_;
my $es = 0;
my $result = '';
&audit("TASK EXEC $task $cmd 2>&1");
open(IN,"echo -e \"yes\\n\" | $task $cmd 2>&1 |");
while(<IN>) {
chop;
$_ =~ s/\x1b.*?m//g; # decolorize
if ( $_ =~ /^\w+ override:/ ) { next; }
$result .= "$_ ";
}
close(IN);
if ( $! ) {
$es = 1;
&audit("FAILED \"$task $cmd\" error closing short pipe");
}
if ( $? != 0 ) {
$es = $?;
&audit("FAILED \"$task $cmd\" returned exit status $?");
}
return ($es,$result);
}
#------------------------------------------------------------------
sub shell_exec {
my ($cmd,$mode) = @_;
endwin();
if ( $clear ne 'NOT_FOUND' ) { system("$clear"); }
if ( $audit ) {
print "$_[0]\r\n";
}
if ( ! fork() ) {
&audit("EXEC $cmd");
exec($cmd);
exit();
}
wait();
if ( $mode eq 'wait' ) {
print "Press return to continue.\r\n";
<STDIN>;
}
&init_curses('refresh');
&draw_screen();
}
return 1;