#!/usr/local/bin/mscript if($1 == ""){ msg(color(RED).'Usage: '.$0.' '); exit(1); } int @count = 4; mutable_primative @exitError = mutable_primitive(true); shell_adv('/bin/ping -c '.@count.' '.$1, array( subshell: false, stdout: closure(@line){ @line = colorize( reg_replace( '(\\d+) bytes from (.*) \\((.*)\\)(.*)', '$1 bytes from &a$2 &r(&b$3&r) $4', @line)); string @error = 'c'; if(reg_match('.*, 0% packet loss.*', @line)){ @error = 'a'; @exitError[] = false; } @line = colorize( reg_replace( '(\\d) packets transmitted, (\\d) received, (\\d+% packet loss)(.*)', '$1 packets transmitted, $2 received, &'.@error.'$3&r$4', @line) ); msg(@line); } ) ); exit(if(@exitError, 1, 0));