Computer Webmaster Gaming Console Graphics Forum

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.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > PHP
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

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.

Google
Reply
 
LinkBack Thread Tools Display Modes
Old 05-20-2007, 5:33 PM   #1
ashore
 
ashore's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default exec() Silent Death

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

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Advertisements
Old 05-20-2007, 5:33 PM   #2
J.O. Aho
 
J.O. Aho's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default exec() Silent Death

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
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 05-20-2007, 5:33 PM   #3
ashore
 
ashore's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default exec() Silent Death

Hey, thanks. I added a sleep(25) call, same results. ????


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 05-20-2007, 5:33 PM   #4
J.O. Aho
 
J.O. Aho's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default exec() Silent Death

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
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 05-20-2007, 5:33 PM   #5
ashore
 
ashore's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default exec() Silent Death

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


 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 05-20-2007, 5:33 PM   #6
shimmyshack
 
shimmyshack's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default exec() Silent Death

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 );



 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Old 05-20-2007, 5:33 PM   #7
shimmyshack
 
shimmyshack's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default exec() Silent Death

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.

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Reply With Quote
Featured Websites
Free Space
Free Space
Free Space Free Space
Reply
Tags: , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Featured Websites




All times are GMT +1. The time now is 5:43 AM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98