executing an exe that's in another directory

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
slak
Forum Newbie
Posts: 1
Joined: Sun Apr 18, 2004 4:43 am

executing an exe that's in another directory

Post by slak »

Hi there,

well i'm pretty noob with php, and i was trying to execute an .exe (or a .bat, I suppose it's the same) file from a php script. If the .exe and the .php files are in the same directory this code works well:

exec("program.bat ".$param1." ".$param2);

But if i try to execute /bin/program.bat like this:

exec("./bin/program.bat ".$param1." ".$param2);

it doesn't work. In my case, it's a program that creates some html files depending on the parameters given, and it doesnt produce any output at the screen.

But the files aren't created, so the file doesnt execute, what shall i do?

Thanks a lot

EDIT: Oh yeah, sorry, i've already had that in my script, but i forgot to put it in this post. :oops: It doesnt work either. :cry:
Last edited by slak on Sun Apr 18, 2004 5:14 am, edited 3 times in total.
steve2004
Forum Newbie
Posts: 14
Joined: Fri Apr 16, 2004 1:18 pm

Post by steve2004 »

try putting a period in front of the path
ie
exec("./bin/program.bat ".$param1." ".$param2);

I think the period tells php to look in other dir or something like that!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

./ is current directory.
../ is previous (parent) directory.
Post Reply