Difference between revisions of "Rp"
From Organic Design wiki
(rp l and rp c) |
m (formatting) |
||
Line 1: | Line 1: | ||
#!/usr/bin/perl | #!/usr/bin/perl | ||
− | |||
$wiki = "http://www.organicdesign.co.nz/wiki/index.php"; | $wiki = "http://www.organicdesign.co.nz/wiki/index.php"; | ||
− | $ps = 'ps lx|egrep peerd[:] | + | $ps = 'ps lx'; |
− | $qxps = qx($ps); | + | |
+ | print "\n"; | ||
+ | $head = ; | ||
+ | $ps = "$ps|egrep peerd[:]"; | ||
+ | $qxps = [split /^/, qx($ps)]->[0].qx($ps); // adds column header | ||
# rp l | # rp l | ||
Line 10: | Line 13: | ||
if ($ARGV[0] eq 'l') { | if ($ARGV[0] eq 'l') { | ||
print "$qxps\n"; | print "$qxps\n"; | ||
+ | $k = $#{[split /^/, $qxps]}; | ||
+ | print ("$k instance".($k>1?"s":"")." of peerd running.\n"); | ||
exit; | exit; | ||
} | } | ||
Line 57: | Line 62: | ||
# kill currently running instances of peerd | # kill currently running instances of peerd | ||
− | $k = | + | $k = -1; |
if ($qxps) { | if ($qxps) { | ||
print "Killing currently running peerd instances:\n"; | print "Killing currently running peerd instances:\n"; | ||
print $qxps; | print $qxps; | ||
− | for (split / | + | for (split /^/, $qxps) { |
qx(kill -9 $1) if /^.+?([0-9]{2,}).+?\d+:\d\d\s*(.+)/; | qx(kill -9 $1) if /^.+?([0-9]{2,}).+?\d+:\d\d\s*(.+)/; | ||
$k++; | $k++; |
Revision as of 23:50, 22 July 2006
- !/usr/bin/perl
$wiki = "http://www.organicdesign.co.nz/wiki/index.php"; $ps = 'ps lx';
print "\n"; $head = ; $ps = "$ps|egrep peerd[:]"; $qxps = [split /^/, qx($ps)]->[0].qx($ps); // adds column header
- rp l
- - lists currently running peerd's and exits
if ($ARGV[0] eq 'l') { print "$qxps\n"; $k = $#{[split /^/, $qxps]}; print ("$k instance".($k>1?"s":"")." of peerd running.\n"); exit; }
- rp c
- - compiles without syncing any files
if ($ARGV[0] ne 'c') {
# Sync files specified in args, or obtain a list of files from Benders fileSync list if ($#ARGV<0) { print "Retrieving files specified in OD:Bender/fileSync list...\n"; $fileSync = qx(curl -s "$wiki?title=Bender/fileSync&xpath:view:"); $fileSync =~ s/<\/ul>.+$//ms;
%articles = $fileSync =~ /
- Compile husk and format output
- Execute compiled result if compiled without any problems