![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| PHP PHP for some can be one of the hardest website programming codes, so do you need help on your PHP script, if it is php4, php5 or lower this is the place for you for any PHP help. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| Under Win32/Vista, PHP 5, I have a batch of files to convert and I'm trying to script that in PHP. The line below fails silently - while the hand-entered version (sans the escapes of course) works correctly. I've tried system() and added an output parameter to the exec() call, but the silence remains. exec ("C:\\Program Files\\FWTools\\ogr2ogr-f \"MapInfo File\" f:\ \out2.mif f:\\tgr24001\\tgr24001cty00.shp"); Ideas on how to troubleshoot this are most welcome. --AS | |||
|
| Advertisements |
| | #2 | ||
| ashore wrote: > Under Win32/Vista, PHP 5, I have a batch of files to convert and I'm > trying to script that in PHP. > > The line below fails silently - while the hand-entered version (sans > the escapes of course) works correctly. I've tried system() and added > an output parameter to the exec() call, but the silence remains. > > exec ("C:\\Program Files\\FWTools\\ogr2ogr-f \"MapInfo File\" f:\ > \out2.mif f:\\tgr24001\\tgr24001cty00.shp"); > > Ideas on how to troubleshoot this are most welcome. --AS > How do you execute the PHP script, from CLI or HTTP? if CLI, the program you use don't report errors to the CLI if something goes wrong. if over HTTP, the convert process takes longer than the timeout time, so the script will be terminated before it finish. -- //Aho | |||
|
| | #4 | ||
| ashore wrote: > Hey, thanks. I added a sleep(25) call, same results. ???? In your php.ini you have a max_execution_time setting, by default php will be run in 30 sec, if it takes longer the script will be terminated. Using sleep() will just make your script will have time to do even less. You need to extend the max_execution_time or make the exec() to start the CLI program in the background (I guess that DOS that microsoft bought once in the time don't support to start things in the background, so this option is out of question). -- //Aho | |||
|
| | #5 | ||
| Thanks, but from the PHP manual re exec(): "... Note: If you start a program using this function and want to leave it running in the background, you have to make sure that the output of that program is redirected to a file or some other output stream or else PHP will hang until the execution of the program ends. ..." AS | |||
|
| | #6 | ||
| On May 6, 3:24 pm, ashore <shor...@gmail.com> wrote: > Under Win32/Vista, PHP 5, I have a batch of files to convert and I'm > trying to script that in PHP. > > The line below fails silently - while the hand-entered version (sans > the escapes of course) works correctly. I've tried system() and added > an output parameter to the exec() call, but the silence remains. > > exec ("C:\\Program Files\\FWTools\\ogr2ogr-f \"MapInfo File\" f:\ > \out2.mif f:\\tgr24001\\tgr24001cty00.shp"); > > Ideas on how to troubleshoot this are most welcome. --AS i fyou hard coded the exec command and it works in a browser, then you need to print out the dynamically generated command, and check that the two are equal. My guess is that they aren't! For instance it would be my guess that in your line above, the dynamically generated line loses the "" around some paths and the call is broken there, and fails. You could try adding &2>1 in order to divert the errors to stdout to see what the actual eror returned is. Heres the way I would do it: //assuming that "ogr2ogr-f" is a program name and that -f isnt an argument. //using single forward slashes which windows understnads just as well. //using single quotes because you dont need php to parse for special whitespace characters like \r or \n $var1 = 'C:/Program Files/FWTools/ogr2ogr-f'; $var2 = 'MapInfo File'; //assuming f: is not a mapped or network drive $var3 = 'f:/out2.mif'; $var4 = 'f:/tgr24001/tgr24001cty00.shp'; //any var that _might_ have spaces in it should be escaped //overkill but it will escape all paths, so if there _are_ spaces things will work $command = '"'.$var1.'" "'.$var2.'" "'.$var3.'" "'.$var4.'"'; exec( $command ); | |||
|
| | #7 | ||
| On May 6, 3:24 pm, ashore <shor...@gmail.com> wrote: > Under Win32/Vista, PHP 5, I have a batch of files to convert and I'm > trying to script that in PHP. > > The line below fails silently - while the hand-entered version (sans > the escapes of course) works correctly. I've tried system() and added > an output parameter to the exec() call, but the silence remains. > > exec ("C:\\Program Files\\FWTools\\ogr2ogr-f \"MapInfo File\" f:\ > \out2.mif f:\\tgr24001\\tgr24001cty00.shp"); > > Ideas on how to troubleshoot this are most welcome. --AS I suppose I should add that you can change working directory uisng chdir() to the dir of the executable, before calling it. This might solve some issues with very badly written executables or batch files, which expect a certain working directory. | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: death, exec, silent |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
| Featured Websites | ||||
|