#!/usr/bin/perl
# This part checks to see if the process is already running
$xcmd = join(" ",@ARGV);
die "No command to wait.\n" if ($xcmd eq "");
if (0) {
if (open(PS, "/usr/bin/ps ax | /usr/bin/grep \"wait4cmd $xcmd\" | /usr/bin/grep -v grep |")) {
@psax = <PS>;
close(PS);
for(@psax) {
s/^\s+//g;
if (/wait4cmd $xcmd/) {
#print "$_";
($pid, @stuff) = split(/\s+/);
#print "$$ pid is $pid and $stuff[0]\n";
if ($pid != $$) {
die "$xcmd already being waited on\n";
# no reason to run if already doing this
}
}
}
}
} # skipped for now bracket
# deal with stdin, stdout, stderr, control terminal, and fork
if (0) {
$TIOCNOTTY = 0x20007471;
close(stdin);
open(stdout, ">/dev/null");
open(stderr, ">/dev/null");
if (open(tty, "/dev/tty")) {
ioctl(tty, $TIOCNOTTY, 0);
close(tty);
}
}
# infinite loop begins here to search for a command
while (1) {
@reply=`$xcmd`;
$strreply=join ' ',@reply;
last if ($strreply =~ /[a-z,A-Z,1-9]/);
sleep(10);
}
print "End\n";
$DATE = `/bin/date +'%Y-%m-%d-%H-%M'`;
system("/usr/bin/logger -p local1.emerg wait4cmd $strreply $DATE ");
system("/usr/bin/wall wait4cmd $strreply ");
Subscribe to:
Post Comments (Atom)
Script to see network interface connection speed
cat network-speed #!/usr/bin/bash # ethtool enp2s0 | grep Speed ethtool $1 | grep Speed # mii-tool -v enp2s0 mii-tool -v $1 network-speed ...
-
This script with it's two related configuration files worked on Raspberry Pi Raspbian Linux. What was always sketchy was the "dri...
-
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #Warn ; Recommended for catching common errors. Send...
-
cat network-speed #!/usr/bin/bash # ethtool enp2s0 | grep Speed ethtool $1 | grep Speed # mii-tool -v enp2s0 mii-tool -v $1 network-speed ...
No comments:
Post a Comment