A Perl script's interaction with Ruby's system call


(Bil Kleb) #1

I’m trying to invoke a perl script (epstopdf) with Ruby’s system command
on a x86 box running GNU/Linux (RH7.2) which begins with the following trickery:

eval ‘(exit $?0)’ && eval ‘exec perl -S $0 ${1+"$@"}’ && eval ‘exec perl -S $0 $argv:q’ if 0;
use strict;

Change by Thomas Esser, Sept. 1998: The above lines allows us to find

perl along $PATH rather than guessing a fixed location. The above

construction should work with most shells.

but I am getting the old “Command not found” error since the trickery fails
to find perl.

If I instead tailor the system call to my particular installation of the epstopdf script
with ‘perl /usr/bin/epstopdf’, the system call works as expected.

Is there a way to use Ruby’s system command with the more general ‘epstopdf’ system
call and the above style of perl trickery?

Thanks in advance,

···


Bil Kleb
NASA Langley Research Center
Hampton, Virginia, USA


(Ned Konz) #2

— epstopdf (make sure that it’s on the PATH, and that it’s chmod +x)
#! /usr/bin/env perl
… other stuff

— your ruby program
system(“epstopdf …”)

···

On Friday 21 June 2002 12:44 pm, Bil Kleb wrote:

I’m trying to invoke a perl script (epstopdf) with Ruby’s system
command on a x86 box running GNU/Linux (RH7.2) which begins with
the following trickery:

eval ‘(exit $?0)’ && eval ‘exec perl -S $0 ${1+"$@"}’ && eval
’exec perl -S $0 $argv:q’ if 0; use strict;

Is there a way to use Ruby’s system command with the more general
’epstopdf’ system call and the above style of perl trickery?


Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE


(Nobuyoshi Nakada) #3

Hi,

···

At Sat, 22 Jun 2002 09:25:18 +0900, Ned Konz wrote:

On Friday 21 June 2002 12:44 pm, Bil Kleb wrote:

I’m trying to invoke a perl script (epstopdf) with Ruby’s system
command on a x86 box running GNU/Linux (RH7.2) which begins with
the following trickery:

eval ‘(exit $?0)’ && eval ‘exec perl -S $0 ${1+"$@"}’ && eval
’exec perl -S $0 $argv:q’ if 0; use strict;

Is there a way to use Ruby’s system command with the more general
’epstopdf’ system call and the above style of perl trickery?

— epstopdf (make sure that it’s on the PATH, and that it’s chmod +x)
#! /usr/bin/env perl
… other stuff

Now ruby can’t run a script without #! line (ruby-bugs:PR#315).


Nobu Nakada


(Bil Kleb) #4

Ned Konz wrote:

#! /usr/bin/env perl
… other stuff

This is third party stuff installed on all sorts of machines that
I have no control over so this is not an option. :frowning:

···

nobu.nokada@softhome.net wrote:

Now ruby can’t run a script without #! line (ruby-bugs:PR#315).

OK, I guess I’ll just use which epstopdf to find the location of
epstopdf for now, and suggest that the author use

#!/usr/bin/env perl

Thanks,

Bil