473,779 Members | 2,072 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1646
d
<fr**********@u sa.com> wrote in message
news:11******** *************@g 47g2000cwa.goog legroups.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
5189
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
2265
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 system chmod unix command in the python script:
0
2063
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 machine or on the server. Our problem is that when we execute the bat file from the vb code it does not work properly. The bat file is used to connect to a commnad line service running on the server and update a file in another system. We can...
4
9897
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 ""type " & nwkfilepath & " > " & pPrinterName & " """
9
3034
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 command only starts the execution of the new file and does not return command to the calling file (the calling file is terminated on the start of execution of the called file)
15
14065
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 Done in C#.... Thanks and Regards, S.Madhanmohan
8
9566
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 : _____ System.Data.SqlClient.SqlException: EXECUTE permission denied on object 'CreateAccount', database 'wizou', schema 'dbo'. at
4
6761
by: alberto | last post by:
How can I execute a command of the operating system like "cls" from a C# code? Thank you
2
5628
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 I put these commands in some sort of executable file? I thought at first a VBScript file (Windows script), but from what I'm reading that is old techology. A script in PowerShell? Not too familiar with this?
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10139
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10075
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7485
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6727
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5504
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3632
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2869
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.