473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to execute two commands within 'system'

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?

Feb 14 '06 #1
2 1633
d
<fr**********@usa.com> wrote in message
news:11*********************@g47g2000cwa.googlegro ups.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"?

dave
Feb 14 '06 #2
'cause I didn't know it ;)

Thank you very much, Dave!

Feb 14 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Lance | last post by:
Hi All, I would like to read commands from a file and execute them in VB, something like reading str = "hello world" into VB and execute it. Any suggestions will be appreciated. Thanks, Lance
3
by: Kory Wheatley | last post by:
Hi all, I've just started to learn Python and I have a question. What is the syntax to embed Unix commands, or call other programs within a Python script? for example I would like to use a...
0
by: Eric Wood | last post by:
We have an application that is accessed using shared drives, client executes program from server. We have already coded the program to create and save the a bat file either locally on the users...
4
by: Kartik | last post by:
Hi, I have an ASP.NET application using VB.NET.I am sending a DOS command to a machine on the network to print a file. This is achieved using xp_cmdshell Dim str As String = "xp_cmdshell...
9
by: Casanova | last post by:
Hello! How can I execute other exe files from within a executable file in GCC. In TurboC 3, the spawn command executes a file and returns command to the calling file. whereas in GCC, the exec...
15
by: Madhanmohan S | last post by:
Hi All, I want to run a command line appplication from C#. When i start the application, it will go into specific mode. After that, i have to give commands to use the application. How Can This Be...
8
by: Jiggaz | last post by:
Hi, In my ASPX Page, i have a form for signup. And whene user click on the button, the event Button1_Click must use a stored procedure. But instead of use stored proc, i get this exception :...
4
by: alberto | last post by:
How can I execute a command of the operating system like "cls" from a C# code? Thank you
2
by: rcook349 | last post by:
I'm trying to automate our builds and publishes of our Windows application (deployed to a website via ClickOnce). I'm getting close, I think, on the commands I need to execute. However, how do...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.