matthewst Posted August 24, 2007 Share Posted August 24, 2007 When I run test1.pl from terminal it works. When I type the commands directly into terminal they work. When I call the script from php all I get is "hello world". test1.pl: #!/usr/bin/perl exec "convert image.pdf image.jpg"; exec "gs -q -sDEVICE=jpeg -dBATCH -dNOPAUSE -dFirstPage=1 -dLastPage=1 -sOutputFile=image.jpg image.pdf 2>&1"; print "hello world"; tester.php: <html> <head> <title>pdf to jpg converter</title> </head> <body> <?php //passthru("convert image.pdg image.jpg"); //passthru("gs -q -sDEVICE=jpeg -dBATCH -dNOPAUSE -dFirstPage=1 -dLastPage=1 -sOutputFile=image.jpg image.pdf 2>&1"); passthru('perl test1.pl'); //$result=passthru("perl test1.pl"); //virtual("perl test1.pl"); ?> </body> </html> also tried: <html> <head> <title>pdf to jpg converter</title> </head> <body> <?php $perl = new Perl(); $perl->eval('print "Hello from perl! "'); print "Bye! "; ?> </body> </html> which produced this error: Fatal error: Class 'Perl' not found in /Library/Tenon/WebServer/WebSites/www.ABCAdvertising.net/beta_web/beta_apps/test/tester.php on line 12 Quote Link to comment https://forums.phpfreaks.com/topic/66501-perl-script-only-half-executes-when-call-from-php/ Share on other sites More sharing options...
effigy Posted August 24, 2007 Share Posted August 24, 2007 You're not checking the return values of exec, and I wouldn't use exec in the first place. Do you need any output from these commands or only return values? Quote Link to comment https://forums.phpfreaks.com/topic/66501-perl-script-only-half-executes-when-call-from-php/#findComment-333047 Share on other sites More sharing options...
matthewst Posted August 24, 2007 Author Share Posted August 24, 2007 ...ummmm...I don't know. All I'm really trying to do is convert a pdf to a jpg with imagemagick and ghostcript. Flow chart: user selects pdf imagemagick and ghostscript convert pdf to jpg, page redirects to new page newley created jpg is placed on the new page for display Quote Link to comment https://forums.phpfreaks.com/topic/66501-perl-script-only-half-executes-when-call-from-php/#findComment-333135 Share on other sites More sharing options...
effigy Posted August 24, 2007 Share Posted August 24, 2007 Check the output and return value of the command similar to example 1993 here. Quote Link to comment https://forums.phpfreaks.com/topic/66501-perl-script-only-half-executes-when-call-from-php/#findComment-333151 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.