Works in telnet but not in perl?

B

Bill H

I have a perl program that is converting a pdf file to a jpg using
imagemagik and gs. Using the following command line in a telnet shell
logged in as the webmaster and in the same directory as the perl
program it works:

cd Pages;/usr/local/bin/convert ZGRH3122CHAP070827063618-1-1.pdf -
resize 300 ZGRH3122CHAP070827063618-1-1.jpg

But when I do it in perl with the following:

system("cd $displaypath;/usr/local/bin/convert $THISPROJECT
$thepagemap[$i].pdf -resize 300 $THISPROJECT$thepagemap[$i].jpg");

which expands out to (same as above):

cd Pages;/usr/local/bin/convert ZGRH3122CHAP070827063618-1-1.pdf -
resize 300 ZGRH3122CHAP070827063618-1-1.jpg

I get this error:

sh: gs: command not found
convert: Postscript delegate failed
`ZGRH3122CHAP070827063618-1-1.pdf'.
convert: missing an image filename `ZGRH3122CHAP070827063618-1-1.jpg'.


Anyone have any clue why I would get this error? Convert works fine,
it just doesn't work with gs (ghostscript) when I call it from the
perl. Also gs is in /usr/local/bin same as convert.

Bill H
 
X

xhoster

Bill H said:
I have a perl program that is converting a pdf file to a jpg using
imagemagik and gs. Using the following command line in a telnet shell
logged in as the webmaster and in the same directory as the perl
program it works:

cd Pages;/usr/local/bin/convert ZGRH3122CHAP070827063618-1-1.pdf -
resize 300 ZGRH3122CHAP070827063618-1-1.jpg

But when I do it in perl with the following:

system("cd $displaypath;/usr/local/bin/convert $THISPROJECT
$thepagemap[$i].pdf -resize 300 $THISPROJECT$thepagemap[$i].jpg");

which expands out to (same as above):

cd Pages;/usr/local/bin/convert ZGRH3122CHAP070827063618-1-1.pdf -
resize 300 ZGRH3122CHAP070827063618-1-1.jpg

I get this error:

sh: gs: command not found
convert: Postscript delegate failed
`ZGRH3122CHAP070827063618-1-1.pdf'.
convert: missing an image filename `ZGRH3122CHAP070827063618-1-1.jpg'.

Anyone have any clue why I would get this error? Convert works fine,
it just doesn't work with gs (ghostscript) when I call it from the
perl. Also gs is in /usr/local/bin same as convert.

It looks to me like /usr/local/bin/convert doesn't use a fully resolved
path to get to gs, but rather depends on gs being the in the search path.
So if you set $ENV{PATH} to include /usr/local/bin/ before calling
/usr/local/bin/convert, it should work. Or you could change convert so
it doesn't rely on search paths to find gs.

Xho
 
B

Bill H

Bill H said:
I have a perl program that is converting a pdf file to a jpg using
imagemagik and gs. Using the following command line in a telnet shell
logged in as the webmaster and in the same directory as the perl
program it works:
cd Pages;/usr/local/bin/convert ZGRH3122CHAP070827063618-1-1.pdf -
resize 300 ZGRH3122CHAP070827063618-1-1.jpg
But when I do it in perl with the following:
system("cd $displaypath;/usr/local/bin/convert $THISPROJECT
$thepagemap[$i].pdf -resize 300 $THISPROJECT$thepagemap[$i].jpg");
which expands out to (same as above):
cd Pages;/usr/local/bin/convert ZGRH3122CHAP070827063618-1-1.pdf -
resize 300 ZGRH3122CHAP070827063618-1-1.jpg
I get this error:
sh: gs: command not found
convert: Postscript delegate failed
`ZGRH3122CHAP070827063618-1-1.pdf'.
convert: missing an image filename `ZGRH3122CHAP070827063618-1-1.jpg'.
Anyone have any clue why I would get this error? Convert works fine,
it just doesn't work with gs (ghostscript) when I call it from the
perl. Also gs is in /usr/local/bin same as convert.

It looks to me like /usr/local/bin/convert doesn't use a fully resolved
path to get to gs, but rather depends on gs being the in the search path.
So if you set $ENV{PATH} to include /usr/local/bin/ before calling
/usr/local/bin/convert, it should work. Or you could change convert so
it doesn't rely on search paths to find gs.

Xho

--
--------------------http://NewsReader.Com/--------------------
Usenet Newsgroup Service $9.95/Month 30GB- Hide quoted text -

- Show quoted text -

That was recommended by the admin at imagemagick also, he also told me
the easier method of just modifying the config file (not mentioned in
the docs that i could find), so it works great now!

Bill H
 
B

Benoit Lefebvre

I have a perl program that is converting a pdf file to a jpg using
imagemagik and gs. Using the following command line in a telnet shell
logged in as the webmaster and in the same directory as the perl
program it works:

cd Pages;/usr/local/bin/convert ZGRH3122CHAP070827063618-1-1.pdf -
resize 300 ZGRH3122CHAP070827063618-1-1.jpg

But when I do it in perl with the following:

system("cd $displaypath;/usr/local/bin/convert $THISPROJECT
$thepagemap[$i].pdf -resize 300 $THISPROJECT$thepagemap[$i].jpg");

which expands out to (same as above):

cd Pages;/usr/local/bin/convert ZGRH3122CHAP070827063618-1-1.pdf -
resize 300 ZGRH3122CHAP070827063618-1-1.jpg

I get this error:

sh: gs: command not found
convert: Postscript delegate failed
`ZGRH3122CHAP070827063618-1-1.pdf'.
convert: missing an image filename `ZGRH3122CHAP070827063618-1-1.jpg'.

Anyone have any clue why I would get this error? Convert works fine,
it just doesn't work with gs (ghostscript) when I call it from the
perl. Also gs is in /usr/local/bin same as convert.

Bill H

Do a chdir() instead of "cd" in your system();

chdir($displaypath);

system("/usr/local/bin/convert $THISPROJECT $thepagemap[$i].pdf -
resize 300 $THISPROJECT$thepagemap[$i].jpg");
 
B

Benoit Lefebvre

Or use the full path to your $THISPROJECT$thepagemap[$i].pdf and
$THISPROJECT$thepagemap[$i].jpg

(sorry for the "double post")

--Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top