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 |
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 |
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 |
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: $ man 7 builtins or $ man 7 bash-builtins. If you install man posix manpages: $ sudo apt-get install manpages-posix manpages-posix-dev 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. /mek -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAEBAgAGBQJQdGAcAAoJEPOy/bGvm8ShL1wIAOLvF4UH4Q3it2V8r7HV9llZ ELLbq+c0mMEN8GZL1X8/pbkeQQVCe/ffDwFtPTBZSLJ/CNz0H7NtFB5jciN/oKvZ gAhDWnerC/pA/bskb8MBu3G6J2Ofq3YkjHzqh6MN8oEiwyjKX+0E9BUVNqYuWJG J rzZLuUO2pZfAmfc1QF9yg2c+mxIATtCs3Hnv+PRZdW25vvK0yw aoc34aUU9A389D 75/xCR5CTzm0LJ8fPi7IdsVfUaV0lCUp3KE+DsZ9ofbRaQO1j12Qr ALss4cCGuxX u9qsRBXmVmGitGi23U/RCRpfv7WPPBhZO+ilGZ8Jwhzqs4jWDZDVcjLz03AHkYM= =kbxA -----END PGP SIGNATURE----- -- 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 |
| All times are GMT. The time now is 04:18 PM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.