Re: PHP Version 5.3.6: confusing CLI [message #177108 is a reply to message #177107] |
Wed, 22 February 2012 15:00 |
tony
Messages: 19 Registered: December 2010
Karma:
|
Junior Member |
|
|
In article <ji2uf9$sca$1(at)news(dot)albasani(dot)net>,
sl@exabyte <sb5309(at)hotmail(dot)com> wrote:
>> It depends on if you have permission to access the CLI processor.
>>
>> Did you ask your hosting company? They should know how they set up
>> their servers.
>
> I was given shell access. After fiddling with it, first with:
>
> php -v: out of memory
> php aa2.php: : out of memory
>
> Then I tried:
>
> . aa2.php
>
> But strange. In aa2.php, I have:
>
> echo "123 cli\n";
> echo "Date: " . date("Y.m.d H:i:s");
>
> I get the followings:
>
> ==start-log==
>
> [~]# . publci_html/aa2.php public_html/aa2.php
> 123 cli\n
That's wrong. The "." command just reads the file for shell commands.
it just so happens that your first echo line is also valid shell syntax.
> -jailshell: public_html/aa2.php: line 3: syntax error near unexpected token
> `('
>
> -jailshell: public_html/aa2.php: line 3: `echo "Date: " . date("Y.m.d
> H:i:s"); '
That's because the second echo line is NOT valid shell syntax.
> ==end-log==
>
> It seems I don't need <?php ..... ?>
Yes, you do.
> But I still have errors.
>
> Gurus please tell me what is this CLI thingie ?
You must start your script with <?php and end it with ?>. You can then
invoke it like this:
# php -q myscript.php
You can also put a shebang line before the opening <?php, like this:
#!/usr/bin/php -q
<?php
echo "123 cli\n";
echo "Date: " . date("Y.m.d H:i:s");
?>
Then if you chmod +x the file, you can invoke it directly like this:
# ./myscript.php
Regards
Tony
--
Tony Mountifield
Work: tony(at)softins(dot)co(dot)uk - http://www.softins.co.uk
Play: tony(at)mountifield(dot)org - http://tony.mountifield.org
|
|
|