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
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: http://lists.debian.org/20121008215827.GA13226@hawking
10-08-2012, 11:23 PM
Mike McClain
Perl: where is the command in system("command -v wget") documented?
Howdy,
On Mon, Oct 08, 2012 at 10:29:42PM +0200, Regid Ichira wrote:
> I am a perl beginner. I stambled upon a perl line
A) subscribe to beginners@perl.org.
> 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?
> Am I right that that line tests whether wget is installed in the
> system? How does it do that?
B) from the bash command line type: help command
HTH,
Mike
--
Humor is an affirmation of dignity,
a declaration of man's superiority to all that befalls him.
- Romain Gary
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: http://lists.debian.org/20121008232349.GA27790@playground
10-09-2012, 01:02 PM
Jon Dowland
Perl: where is the command in system("command -v wget") documented?
On Mon, Oct 08, 2012 at 10:58:27PM +0100, Karl E. Jorgensen wrote:
> "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.
For this reason I'd shy away from relying on 'command' in a script where you
cannot guarantee the execution shell. 'which' is a suitable shell-agnostic
alternative.
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: http://lists.debian.org/20121009130242.GC17431@debian
10-09-2012, 05:36 PM
Mat Kovach
Perl: where is the command in system("command -v wget") documented?
Regid Ichira writes:
> 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?
The command, command is a shell builtin. On Debian you can find
information about it in:
You should find further information about it under
$ man 1p command
> Am I right that that line tests whether wget is installed in the
>system? How does it do that?
- From the man page:
``The command utility shall cause the shell to treat the arguments as a
simple command, suppressing the shell function lookup that is described
in Command Search and Execution, item 1b.'
So, basically it will run the wget, ignoring some shell functions
and builtins. This is used often as a security measure.
--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20121009174338.D776A148@bendel.debian.org">http://lists.debian.org/20121009174338.D776A148@bendel.debian.org