473,505 Members | 14,950 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP exec

Hello All . . .

I need some help about exec command.

I have create an executable that return the System Drives. It is based
on DOS and does not need any parameter.

I have create my php script that executes the executable i've create
and the source code is the following :

##########################################
php:

exec("SystemDrives", $out);

for($i = 0; $i <= sizeof($out)-1; $i++)
{
echo $out[$i];
execMediaID($out[$i]);
echo "<br />";
}
##########################################

The php script is in the followin directory :

http://localhost/My Application/Applications/SystemDrives.php

in the same directory is and the executable

http://localhost/My Application/Application/SystemDrives.exe
The problem is that if i will call the SystemDrives.php from parent
directory then i don't get any result.

For example if i will execute the following script i don't have any
result
php:
index.php
<?php
include_once("Applications/SystemDrives.php");
?>
that the index located in the following directory

http://localhost/My Application/index.php

What can i do to execute the directories.
------------------------------------------------------------------------------------------------------------------------------------------

Thanks a lot . . .

May 7 '07 #1
4 2533
On May 7, 7:41 am, CorfuVBProgrammer <merianosni...@gmail.comwrote:
Hello All . . .

I need some help about exec command.

I have create an executable that return the System Drives. It is based
on DOS and does not need any parameter.

I have create my php script that executes the executable i've create
and the source code is the following :

##########################################
php:

exec("SystemDrives", $out);

for($i = 0; $i <= sizeof($out)-1; $i++)
{
echo $out[$i];
execMediaID($out[$i]);
echo "<br />";

}

##########################################

The php script is in the followin directory :

http://localhost/MyApplication/Appli...stemDrives.php

in the same directory is and the executable

http://localhost/MyApplication/Appli...stemDrives.exe

The problem is that if i will call the SystemDrives.php from parent
directory then i don't get any result.

For example if i will execute the following script i don't have any
result

php:
index.php
<?php
include_once("Applications/SystemDrives.php");
?>

that the index located in the following directory

http://localhost/MyApplication/index.php

What can i do to execute the directories.
------------------------------------------------------------------------------------------------------------------------------------------

Thanks a lot . . .
use absolute paths, or use chdir() before you attempt to call an
executable, this is a path issue. the OS will only find the exe if you
tell it where it lives, or if the exe is in the PATH.

May 7 '07 #2
On May 7, 11:27 am, shimmyshack <matt.fa...@gmail.comwrote:
On May 7, 7:41 am, CorfuVBProgrammer <merianosni...@gmail.comwrote:
Hello All . . .
I need some help about exec command.
I have create an executable that return the System Drives. It is based
on DOS and does not need any parameter.
I have create my php script that executes the executable i've create
and the source code is the following :
##########################################
php:
exec("SystemDrives", $out);
for($i = 0; $i <= sizeof($out)-1; $i++)
{
echo $out[$i];
execMediaID($out[$i]);
echo "<br />";
}
##########################################
The php script is in the followin directory :
http://localhost/MyApplication/Appli...stemDrives.php
in the same directory is and the executable
http://localhost/MyApplication/Appli...stemDrives.exe
The problem is that if i will call the SystemDrives.php from parent
directory then i don't get any result.
For example if i will execute the following script i don't have any
result
php:
index.php
<?php
include_once("Applications/SystemDrives.php");
?>
that the index located in the following directory
http://localhost/MyApplication/index.php
What can i do to execute the directories.
------------------------------------------------------------------------------------------------------------------------------------------
Thanks a lot . . .

use absolute paths, or use chdir() before you attempt to call an
executable, this is a path issue. the OS will only find the exe if you
tell it where it lives, or if the exe is in the PATH.
also it might be worth saying that on your OS, do you know which is
executed first
program.bat
program.com
program.exe
so when you use the command
exec('program',$out);
what are you going to get in a directory where all three exist, or if
none exist!! (so the OS searches the path)
is there any harm in being exact?

May 7 '07 #3
CorfuVBProgrammer wrote:
What can i do to execute the directories.
Aaaaaahhh, you need to program in a unix system some day, and you'll be
enlightened.

Either refer to the parent directory (".."), or use the $PATH environment
variable.

--
----------------------------------
Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-

Fortune: You will be attacked next Wednesday at 3:15 p.m. by six samurai
sword wielding purple fish glued to Harley-Davidson motorcycles.

Oh, and have a nice day!
-- Bryce Nesbitt '84

May 7 '07 #4
The problem solved . . .

I changes the working directory and now i can execute perfectly my
executable . . . .
Thanks a lot . . . . :D

Kind Regards

Merianos Nikos

May 7 '07 #5

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

Similar topics

6
8365
by: Hal Vaughan | last post by:
I have a script used to find and run Java on a Windows system.  It worked fine on original tests (on a Windows XP system).  It's now running on a Windows 2000 (sp3) system, and it won't work -- the...
1
2217
by: Andr? Roberge | last post by:
I have the following two files: #--testexec.py-- def exec_code(co): try: exec co except: print "error" #-- test.py--
0
10158
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
17
7881
by: comp.lang.tcl | last post by:
The TCL command I am using will do a command-line action on a PHP script: set cannotRunPHP I have to do it this way as both the TCL script and the PHP script run as CLI. However, "info.php"...
5
2419
by: TPJ | last post by:
I have the following code: ----------------------------------- def f(): def g(): a = 'a' # marked line 1 exec 'a = "b"' in globals(), locals() print "g: a =", a
4
2349
by: Michael | last post by:
Hi, I'm having difficulty finding any previous discussion on this -- I keep finding people either having problems calling os.exec(lepev), or with using python's exec statement. Neither of...
21
7796
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
2
3077
by: xml0x1a | last post by:
How do I use exec? Python 2.4.3 ---- from math import * G = 1 def d(): L = 1 exec "def f(x): return L + log(G) " in globals(), locals() f(1)
26
3623
by: warth33 | last post by:
Hello I have a php site. Some page needs to call an external program. The programs are home made c# applications. It uses to work without problem. For a while. Maybe it work for some hour....
23
9337
by: Maarten | last post by:
Howdy, Recently I switched from a Windows PC to Mac OS-X 10.5 (php v5.2.6) and I have a little problem with one function within my cd-management script. For extracting a bit of info from my...
0
7216
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
7303
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
7367
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...
1
7018
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...
1
5028
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...
0
4699
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...
0
3187
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...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
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 ...

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.