Works in telnet but not in perl?

Discussion in 'Perl Misc' started by Bill H, Sep 6, 2007.

  1. Bill H

    Bill H Guest

    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
     
    Bill H, Sep 6, 2007
    #1
    1. Advertising

  2. Bill H

    Guest

    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
     
    , Sep 6, 2007
    #2
    1. Advertising

  3. Bill H

    Bill H Guest

    On Sep 6, 1:33 pm, 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
     
    Bill H, Sep 6, 2007
    #3
  4. 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");
     
    Benoit Lefebvre, Sep 6, 2007
    #4
  5. Or use the full path to your $THISPROJECT$thepagemap[$i].pdf and
    $THISPROJECT$thepagemap[$i].jpg

    (sorry for the "double post")

    --Ben
     
    Benoit Lefebvre, Sep 6, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. F. GEIGER
    Replies:
    3
    Views:
    811
    F. GEIGER
    Aug 6, 2004
  2. David Wang
    Replies:
    0
    Views:
    754
    David Wang
    Dec 1, 2006
  3. Jim Isaacson
    Replies:
    5
    Views:
    628
    Default User
    Nov 5, 2004
  4. Carcarius
    Replies:
    0
    Views:
    328
    Carcarius
    Dec 6, 2007
  5. Eric Lewton
    Replies:
    3
    Views:
    125
    Eric Lewton
    Dec 1, 2003
Loading...

Share This Page