| 
	
 | 
 Posted by shimmyshack on 05/06/07 23:51 
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 );
 
  
Navigation:
[Reply to this message] 
 |