473,326 Members | 2,128 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,326 software developers and data experts.

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 2126
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
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...
0
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...
2
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...
2
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
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...
2
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...
1
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...
1
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...
2
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: ...
4
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.