Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

How to run pbmtextps from inside Perl script

by James Board (Beadle)
on Feb 08, 2014 at 17:54 UTC ( [id://1074043]=perlquestion: print w/replies, xml ) Need Help??

James Board has asked for the wisdom of the Perl Monks concerning the following question:

I'm on a Linux machine and I'm coding a Perl script to generate images with text in by calling pbmtextps multiple times. When I try to run pbmtextps in Perl with a system call like this

system("pbmtextps -fontsize 24 SampleText > out.pbm");

I get this error message

pbmtextps: failed to run Ghostscript process: rc=-1

However, if I run the exact same pbmtextps command from the command-line outside of Perl, it runs with no errors.

Why does it cause the ghostscript error when I run it from inside a Perl script?

Also, I tried to hack around this by creating a C program which does the exact same thing with a C system call. That works correctly from the command line. No errors. But then when I try to run that C program from the Perl script with a call to system(), I get the same ghostscript error.

ANSWER: I solved it. The problem was this line in the PERL script:

 $SIG{CHLD} = 'IGNORE';

When I got rid of that (which I need for other things, but not in this script) it worked okay.

Replies are listed 'Best First'.
Re: How to run pbmtextps from inside Perl script
by stefbv (Curate) on Feb 08, 2014 at 18:58 UTC

    I can't reproduce you error, it runs fine from the shell, from a script and with:

    perl -e 'system("pbmtextps -fontsize 24 SampleText > out.pbm")'

    and the 'out.pbm' file is valid.

      Thanks, I eventually figured it out. See ANSWER in original queston.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1074043]
Approved by stefbv
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2024-04-25 11:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found