~/paste/19322
~/paste/19322
~/paste/19322

  1. #!/usr/local/bin/mscript
  2.  
  3. if($1 == ""){
  4.         msg(color(RED).'Usage: '.$0.' <host>');
  5.         exit(1);
  6. }
  7. int @count = 4;
  8. mutable_primative @exitError = mutable_primitive(true);
  9. shell_adv('/bin/ping -c '.@count.' '.$1,
  10.         array(
  11.                 subshell: false,
  12.                 stdout: closure(@line){
  13.                         @line = colorize(
  14.                                 reg_replace(
  15.                                         '(\\d+) bytes from (.*) \\((.*)\\)(.*)',
  16.                                         '$1 bytes from &a$2 &r(&b$3&r) $4', @line));
  17.                         string @error = 'c';
  18.                         if(reg_match('.*, 0% packet loss.*', @line)){
  19.                                 @error = 'a';
  20.                                 @exitError[] = false;
  21.                         }
  22.                         @line = colorize(
  23.                                 reg_replace(
  24.                                         '(\\d) packets transmitted, (\\d) received, (\\d+% packet loss)(.*)',
  25.                                         '$1 packets transmitted, $2 received, &'.@error.'$3&r$4',
  26.                                         @line)
  27.                         );
  28.                         msg(@line);
  29.                 }
  30.         )
  31. );
  32. exit(if(@exitError, 1, 0));
Language: commandhelper
Posted by Anonymous at 10 Mar 2016, 09:48:31 UTC