You are here: Re: How to execute two commands within 'system' « PHP Programming Language « IT news, forums, messages
Re: How to execute two commands within 'system'

Posted by Gary L. Burnore on 02/15/06 00:47

On Tue, 14 Feb 2006 17:30:43 GMT, "d" <d@example.com> wrote:

><francescomoi@usa.com> wrote in message
>news:1139935640.768005.71940@g47g2000cwa.googlegroups.com...
>> Hi.
>>
>> On PHP4, I want to execute these two system commands:
>> # cd /home/foo1/foo2
>> # /usr/local/php/bin/php /home/foo1/foo2/script.php
>>
>> If I do it via shell, it works ok.
>>
>> But If I do:
>> -------
>> system("cd /home/foo1/foo2/", $retval);
>> system("/usr/local/php/bin/php /home/foo1/foo2/script.php", $retval);
>> --------
>>
>> I get this error message:
>> -----
>> Fatal error: main(): Failed opening required '../config/config.php'
>> (include_path='.:/usr/local/php/lib/php') in /home/foo1/foo2/script.php
>> on line 2
>> -----
>>
>> This error is caused by the fact that the script is not executed in the
>> right directory.
>>
>> Any similar experience?
>
>Why don't you use the chdir function instead of system()ing a "cd"?
>
You're absolutely right of course, but just to answer the question:

system("<cd /home/foo1/foo2 ; /usr/local/php/bin/php
/home/foo1/foo2/script.php)", $retval);

(all on one line)

Should work.
--
gburnore at DataBasix dot Com
---------------------------------------------------------------------------
How you look depends on where you go.
---------------------------------------------------------------------------
Gary L. Burnore | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
Official .sig, Accept no substitutes. | ÝÛ³ºÝ³Þ³ºÝ³³Ýۺݳ޳ºÝ³Ý³Þ³ºÝ³ÝÝÛ³
| ÝÛ 0 1 7 2 3 / Ý³Þ 3 7 4 9 3 0 Û³
Black Helicopter Repair Services, Ltd.| Official Proof of Purchase
===========================================================================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация