When it comes to linux, I'm the man.
So hit me with your questions!
So hit me with your questions!
you mean, type: echo $PATHsorry charly, I missed your post.
type $PATH in your console windows, and you'll see the list af all directories that linux searches when you type a command.
If you add up all commands in these directories, you'll end up with more than 1000 for sure...
Thanks for the history and apropos tricks, I didn't know them, and I'll be using them for sure.
The tab can be very useful, but your apropos thing is much better when you dont know the name of the command.
#!/usr/bin/php -q
$ip = 1.2.3.4;
exec("ping $ip -c 2 -W 2|grep "64 bytes"", $aOut);
if (count($aOut)!=2) {
exec("logger Host $ip is down.");
}
It is true that you have to write more code to process the output, but on the other hand I find PHP to be more readable and it has a lot of additional features, like tons of extensions, objects, etc... But I have to say reason n.1 is that I already know it inside out.not only is this too much code, everything you need is already there, and you're adding the PHP syntactic sugar around it, here's the one line bash version:#!/usr/bin/php -q $ip = 1.2.3.4; exec("ping $ip -c 2 -W 2|grep "64 bytes"", $aOut); if (count($aOut)!=2) { exec("logger Host $ip is down."); }
$ (ping google.com -c 1 | grep "64 bytes") || logger "Host google.com is down.";
it's no point to use PHP since you're exec'ing the commands already.0 is false, everything else is true.megalomania, this is from the grep manpage:
Normally, exit status is 0 if selected lines are found and 1 otherwise.
But the exit status is 2 if an error occurred, unless the -q or --quiet
or --silent option is used and a selected line is found.
how does that map to true/false?