Works in telnet but not in perl?

Works in telnet but not in perl?

am 06.09.2007 18:48:43 von 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

Re: Works in telnet but not in perl?

am 06.09.2007 19:11:27 von Glenn Jackman

At 2007-09-06 12:48PM, "Bill H" wrote:
[...]
> 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.

What's $ENV{PATH} ? What other environment differences exist?

--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry

Re: Works in telnet but not in perl?

am 06.09.2007 19:33:45 von xhoster

Bill H wrote:
> 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

Re: Works in telnet but not in perl?

am 06.09.2007 19:46:26 von Bill H

On Sep 6, 1:33 pm, xhos...@gmail.com wrote:
> Bill H wrote:
> > 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

Re: Works in telnet but not in perl?

am 06.09.2007 22:24:37 von Benoit Lefebvre

On Sep 6, 12:48 pm, Bill H wrote:
> 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");

Re: Works in telnet but not in perl?

am 06.09.2007 22:26:37 von Benoit Lefebvre

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

(sorry for the "double post")

--Ben