0

I really need some help for a problem. I'm trying to use the exec() PHP function which is directly integrated on PHP, but it doesn't work.

I've tried this :

$directory = "C:/wamp/www/ADA-WEB/Conversion";
$file ="/main.exe";
chmod($directory, 0600);
exec($directory.$file);

But nothing goes on. So, i've tried to see if an error was reported on the Apache Log, and this is what appears :

raised ADA.IO_EXCEPTIONS.NAME_ERROR : convertir\EXPORT.DAT: No such file or directory

It's a typical error that ADA may raise. But i don't understand why this error is generated. It seems that PHP runs the file on a random folder (perhaps a temp one). When i launch directly the exe on windows i don't have this kind of problem.

If you should help...

Thanks a lot.

Nicolas

  • bug in php exec() or bug in your code, i know which one i would bet on. –  May 30 '13 at 20:29
  • Does your ADA program rely on any environment variables being set. Try running this php script from the command line and see if you get the same error. – Orangepill May 30 '13 at 20:31
  • 1
    It's looking for the file having the relative pathname "convertir\EXPORT.DAT" and can't find it. – Marc C May 30 '13 at 20:54
  • 1
    Try chdir($directory) first: – Jorge Muñoz May 30 '13 at 21:10
  • 1
    Check out this [Q&A](http://stackoverflow.com/questions/1679045/php-exec-command-how-to-specify-working-directory). – Simon Wright May 30 '13 at 21:14
  • Hello all, The Ada program works perfectly without being process through php. Why changing the directory? It seems that the problem comes from windows which doesn't allow running a program with a navigator... – Nicolas Girot May 31 '13 at 09:39

3 Answers3

2

You could consider using http://php.net/manual/fr/function.chdir.php before launching your ada application. This way you can control what is the current directory used when running your binary

$directory = "C:/wamp/www/ADA-WEB/Conversion";
$file ="/main.exe";
$current = getcwd();
chdir($direcoty);
chmod($directory, 0600);
exec($directory.$file);
chdir($current);
Lancelot SIX
  • 156
  • 2
0

Well, i've changed my mind, going on another direction..

After more searches about this problem it really seems that the problem is not because of the exec() function but because Windows doesn't allow a program to be executed through a navigator.

Thanks for your answers.

Nicolas

0

There may be alternative approaches to the problem. that sidestep the limitation (apparently with Windows) that you are facing.

If you're driving an Ada program through a web-based interface, the Ada Web Server (AWS) toolkit is a way to build a webserver right into your program - it's easy to use, and fast too. Apparently there is some other toolkit called AWS, but the one I mean is here: with an introduction here. See also this StackOverflow question for some other views on the toolkit.

Community
  • 1
  • 1