Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to execute two commands within 'system'

Status
Not open for further replies.

cadbilbao

Programmer
Apr 9, 2001
233
ES
Hi.

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?
 
I don't see any reference to '../config/config.php' in your example uses of system(), so I'll assum that the error is coming from the script you're trying to run.

Whatever line of code contains '../config/config.php', change it to a filesystem absolute path.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top