Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script on half runs when called from php

Status
Not open for further replies.

matthewst

IS-IT--Management
May 1, 2007
25
0
0
US
I can run the following script from the web it won't convert but it does display "hello world".

test1.pl
Code:
#!/usr/bin/perl
exec "convert image.pdf image.jpg";
print "hello world";

If I'm on the server I can type "perl test1.pl" and it will convert and display hello world.
 
You should put in full path's to everything. Full path to the convert command, full path to your files. If you don't know where the files are you can use whereis on *nix.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
the exec command is failing matthew - it's not actually running "convert" - if it were, even if convert were giving you an error msg, you wouldn't see hello world. The exec command effectively stops the script right there if it works - commands after a line with exec on it shouldn't execute.

Mike

When working on any project the value of other people is exactly that - they are other people, with views that don't necessarily match yours. This mismatch, between their views and the view you've been contentedly assuming is right, is where that value lies.
 
Change to using back ticks instead of exec.
@output = `/path/to/convert /path/to/file1 /path/to/file2`;
print "@output\n";



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
When I run your script through php it just displays "hello world" (which i placed after "print "@output\n"). If I run it in terminal i get the following error:
Code:
dyld: Library not loaded: /usr/X11R6/lib/libdpstk.1.dylib
Referenced from: /usr/local/bin/convert
Reason: no suitable image found. Did find:
/usr/X11R6/lib/libdpstk.1.dylib: mach-o, but wrong architecture

Thats the same error I get when calling convert in php which is why I'm trying to make it work with perl. I found and place a copy of libdpstk.1.dylib in the correct location but it still doesn't want to work.
 
It works from the command line, it works in a perl script. It won't work when called from php.
 
Probably a permissions/path type issue. When you run it from the web site then it is being ran as the user that runs the httpd daemon (ps -ef | grep httpd) normally something like that.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
No.. you need to see what user your web site is being run as.. are you on windows or unix?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
do a
ps -ef | grep httpd

and it will show you what user httpd is running as. You should test your scripts as this user.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
I get an illegal option with the -ef combo. If I just run the -e I get "11474 p1 S+ 0:00.00 grep httpd TERM_PROGRAM=Apple_Terminal TERM=xterm-col
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top