473,769 Members | 5,757 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

system() to execute a config-file and sending variables to php

I've to read variables out of a config-file, that is stored on a
Linux-machine.
When I connect to the server with puTTY, I can execute the config with:
.. /usr/local/webspace/config

then I can echo the contained variables:
echo $var1
everything works fine.

Now I want to execute the config by a php-script.
I try to open the file with the system() command:
system('. /usr/local/webspace/config', $retval);

I hoped to get the same variables now for doing some stuff with them in php.
But there are no variables, but the $retval = 0

Any ideas?

Arne Lund
Jul 17 '05 #1
1 2147
On Thu, 13 May 2004 17:34:14 +0200, Arne Lund wrote:
I've to read variables out of a config-file, that is stored on a
Linux-machine.
When I connect to the server with puTTY, I can execute the config with:
. /usr/local/webspace/config

then I can echo the contained variables:
echo $var1
everything works fine.

Now I want to execute the config by a php-script.
I try to open the file with the system() command:
system('. /usr/local/webspace/config', $retval);

I hoped to get the same variables now for doing some stuff with them in php.
But there are no variables, but the $retval = 0

Any ideas?

Arne Lund


The problem is that $retval returns the return value of the script,
_not_ the output of the script. To get the output, do this:

$output = system('. /usr/local/webspace/config', $retval);

Many Unix programs set a return value after executing. For example, if you
use 'grep', it returns a '0' if it was successful, '1' if not. Let's say
'ls' returns this:
..
...
readme.txt
foo.c

Now 'ls | grep foo.c' returns
foo.c
and grep has set the return value to '0'. To get the return value, you can
use 'echo $?' at the shell prompt after executing the above command. If
you do 'ls | grep file.txt', the output is nothing, but the return value
of grep will be '1'.

So when you were getting a '0' for $retval, that meant that your script
executed successfully with a return status of '0'.

DrTebi
Jul 17 '05 #2

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

Similar topics

0
1211
by: Luis Esteban Valencia Muñoz | last post by:
I have a big project I did on the developing company I am working, it has the connection string on the web.config. and It works perfectly in our testing environment. I want to make a setup project with this features. - It must ask the sql server name sa password. - it must execute a .SQL server I generated to create the database and objects. - It must then change in the web.config the sql server connection string.
0
2469
by: Cameron | last post by:
Hi All, I've just written a small program to use a locally hosted webservice which works fine. However I've also written a SOAPExtension for the client and I'm having trouble with the configuration (getting a ConfigurationException complaining about a valid type name). The following is the coded DebugExtension which extends SoapExtension
2
2439
by: Christine.Misseri | last post by:
Hi all, I'm sure someone knows about this problem. I have an Access database designed in Access 2000, connected to an ORACLE 8i back end. On the ORACLE side I have stored procedures, triggers and views that kick off at different times. My Access 2000 database works well. Problem: I converted the database to Access 2003 am using ORACLE again as my back end (they have updated the drivers in Oracle to 9i). I an trying
2
1646
by: francescomoi | last post by:
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: -------
9
2185
by: Arpan | last post by:
If I am not wrong, System.IO is one of the seven namespaces that get imported in all ASP.NET page automatically but in the following code: <%@ Import Namespace="System.IO" %> <script runat="server"> Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs) Dim ioFileInfo As New FileInfo("C:\Inetpub\wwwroot\File1.asp") lblOutput.Text = "Name: " & ioFileInfo.Name & "<br>" lblOutput.Text += "Path: " & ioFileInfo.DirectoryName & "<br>"
2
14379
by: job | last post by:
In a sharepoint setup using smartpart to load our user controls using enterprise blocks (data) we are getting some strange errors (logged to the event log). We dont get the error all the time. When we get the error CPU goes 100% We have been through all we can think of, but have not been able to locate the source to the error. Any suggestions?
1
7518
by: goc | last post by:
I have a Web Farm, that fetches its database-data from a separate database-server. Today I was forced to go over to .NET 2.0 (since 1.1 can't be installed on Windows Vista x64), and it brought about quite alot of problems. But now I've sorted out everything except one problem that I just can't get to disappear: As soon as I try to connect to a database from my code and run a query, I get an exception thrown: Check: Request for the...
1
2446
by: empriser | last post by:
I write a socket program. After accept client connection , server fork a child process, how do keep this execute sequence? Thanks pid = fork(); if ( pid 0 ){ CONFIG CHILD PROCESS TABLE }else{ WAIT UNTIL father process config child process
2
3981
by: astolpho | last post by:
I am using a slightly outdated reference book on J2EE programming. It gives 2 methods of creating a database used in its casestudies. The first is an ANT script that gives the following output: D:\original\CaseStudy-2-5\CaseStudy\Day02\exercise>asant database Buildfile: build.xml env-user: prop-user: set-user:
4
1991
by: lukaszmn | last post by:
Hey I've been searching the internet and manuals for help for hours and I'm still clueless. I wanted to delete a file in /var/www/html/ lista from a script /var/www/html/lista-drop.php. Apache runs as user & group apache. I've chowned & chgrouped the file and parent directory (lista). I've chmodded 777 both. I did so from both shell and the script. From the script, I can read files from the folder, I can create a file and delete it. It...
0
9583
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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
10039
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...
0
9860
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8869
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
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
5297
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...
1
3955
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3560
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.