Re: whoami explanation
| From: | Peter Ford | Date: | Wed, 04 Mar 2009 09:26:39 +0000 |
| Subject: | Re: whoami explanation | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-289221@lists.php.net to get a copy of this message | ||
PJ wrote:
> Per Jessen wrote:
>> PJ wrote:
>>
>>
>>> forgot to add:
>>> What's the difference between back ticks or quotes and regular single
>>> quotes?
>>>
>> text in back ticks is executed via a shell, text in single quotes isn't.
>>
> Ok, but how does this relate to a command passed from a php Web page?
> I don't understand the processus.
> I use bash on my FreeBSD and have not needed a back quote yet that I can
> recall... and on WinXP?
In your bash shell, you can use backticks in a similar way to how PHP uses them
- to assign the output of a command to a variable. For example:
LIST=
find . -name '*.php'
will fill up the shell variable $LIST with all the files with extension .php
below the current directory.
You could then do something with that variable, like
for FILE in $LIST
do
cp $FILE $FILE.bak
done
to make a backup copy of each of the files.
In PHP, something like
<?php
$list = find . -name '*.php';
foreach (explode(' ',$list) as $file)
{
copy ($file,"{$file}.bak");
}
?>
should do much the same thing (if permissions etc. allow...)
Note that in both of these examples, filenames with spaces in them will blow the
whole thing up :(
--
Peter Ford phone: 01580 893333
Developer fax: 01580 893399
Justcroft International Ltd., Staplehurst, Kent