Re: Perl: where is the command in system("command -v wget") documented?
Hi
On Mon, Oct 08, 2012 at 09:29:42PM +0100, Regid Ichira wrote:
> I am a perl beginner. I stambled upon a perl line
>
> if (system("command -v wget >/dev/null 2>&1") == 0)
>
> I was able to find perl's documentation for system. But where is
> the documentation for command?
"command" is a shell built-in command - so you should find it in the
documentation for your shell - e.g. "man sh" should get you to the
right manual page. Exactly *which* shell this is, depends on your
system, but it is most likely "bash" or "dash" which provides /bin/sh.
Searching for the string "command" in the manual page is bound to give
LOTs of hits - try searching for "BUILTINS" instead - once you get to
the list of built-in commands, you should find them in asciibetical
order.
> Am I right that that line tests whether wget is installed in the
> system? How does it do that?
It checks whether the "wget" command is available in $PATH, yes. So
this can be fooled if you have $HOME/bin in your $PATH and you create
your own shell script named "wget". The "> /dev/null 2>&1" has the
effect of supressing any output to stdout and stderr, thus making the
command silent regardless of whether it succeeds or fails.
Hope this helps
--
Karl E. Jorgensen
Reply to: