blob: 5016c8d4401056ebfa2f277f9f7b2f4d9e7e5fe9 (
plain)
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
|
#!/usr/local/bin/perl
use warnings;
use strict;
use Term::ANSIColor;
use File::Tee qw(tee);
use constant DEFAULT_USER => 'jozan';
use constant LOG_FILE => '/var/log/system-upgrade.log';
use constant {
DASH_PATH => '/usr/local/bin/dash',
SU_PATH => '/usr/bin/su',
GREP_PATH => '/usr/bin/grep',
WC_PATH => '/usr/bin/wc',
TR_PATH => '/usr/bin/tr',
PORTMASTER_PATH => '/usr/local/sbin/portmaster',
ESPEAK_PATH => '/usr/local/bin/espeak',
NOTIFY_PATH => '/usr/local/bin/notify-send',
};
sub shell {
system(
DASH_PATH,
'-c',
$_[0]
);
}
sub user_shell {
system(
DASH_PATH,
'-c',
SU_PATH . ' ' . DEFAULT_USER . ' << EOF
' . $_[0] . '
EOF'
);
}
sub main {
user_shell(ESPEAK_PATH . ' test &');
user_shell(NOTIFY_PATH . ' qweqwe');
shell('touch /qwe');
exit;
}
main();
__END__
|