Thank you a thousand times folks!
I'm working in a company for school without earning money (don't know the english word) and got a little bit stressed because it didn't work.
pbulteel, your script doesn't work because you have to return it in the format var1:10 var2:66 when you return more than 1 var. But just changing the print line in your code worked. Also had to make some other changes. Left out the linux part which didn't work and the my $ping stuff
what does "my $var" means? Declaring the var? I can use variables without declaring. Know nothing about perl
Anyway, it is now working fine!
Now I can try the second script to also receive average and min values
Code: Select all
#!/usr/bin/perl
$host = $ARGV[1];
$pingcount = $ARGV[0];
$ping = `ping -n $pingcount $host`;
# starts some variables
$rtt;
$loss;
# check for this word and grab it's value
$ping =~ /Average = (.*)ms/;
$rtt = $1;
# check for the % sign inside parens and grab it's value
$ping =~ /(\d*)%/;
$loss = $1;
#print the values
print "rtt:$rtt loss:$loss";
Last question: I am using a dutch windows, so he doesn't return 'average: 1 ms', but 'gemiddelde: 1 ms'
how can I use the OR (||) operator in the regular expression to check both values?