Re: Re: whoami explanation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2009-03-03 at 11:27 -0500, PJ wrote:
> Shawn McKenzie wrote:
> > PJ wrote:
> >   
> >> This really needs some explanation
> >> I found this on the web:
> >> <?php echo `whoami`; ?>
> >> with it there was the comment "the direction of those single-quotes matters"
> >> (WHY ?)
> >> and it works....
> >>
> >> But this (_*FROM THE PHP MANUAL***_ * -  exec()* executes the given
> >> /command/ ) does not,
> >> COPIED AND PASTED:
> >> |<?php
> >> // outputs the username that owns the running php/httpd process
> >> // (on a system with the "whoami" executable in the path)
> >> echo exec('whoami');
> >> ?> |
> >> What is going on here?
> >> And I often find such discrepancies in examples - and some wonder why I
> >> seem to be so stupid... and don't know the fundamentals... :-\
> >>     
> >
> > Others have shown how exec() returns the output.  If you use
> > shell_exec() it's the same as using the backticks:
> >
> > <?php echo `whoami`; ?>
> >
> > -or-
> >
> > <?php echo shell_exec("whoami"); ?>
> >
> > You can use single quotes here also, i used double so you can easily
> > tell they are not backticks
> >   
> What is not clear to me is why would I need to use a shell? What kind of
> situations call for it's use?

You must be a point and clicker. Many, many, many people use the shell
to perform basic system administration, edit config files, even edit
source code. There are thousands of shell commands available at the
touch of your fingertips while in a shell. Using the backticks or exec()
function allows one to utilize these programs as part of a larger
program.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux