Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: perl script inside a shell script

by dchetlin (Friar)
on Dec 12, 2000 at 03:44 UTC ( [id://46182]=note: print w/replies, xml ) Need Help??


in reply to perl script inside a shell script

Ah, tailor-made for the little-used `-x' option for perl. Observe:

[~] $ cat test.sh #!/bin/sh echo "In shell part" FOO=`/usr/bin/perl -x $0` echo <<'__END__' > /dev/null #!/usr/bin/perl -wl print "In perl"; __END__ echo "Perl said: $FOO" echo "Back in shell" [~] $ sh test.sh In shell part Perl said: In perl Back in shell [~] $

Ain't that fun? See perlrun for details on `-x'.

-dlc

Replies are listed 'Best First'.
Re: Re: perl script inside a shell script
by Anonymous Monk on Jun 27, 2002 at 18:06 UTC
    I get error testing the script...have not been able to figure out y...any idea? this is waht I get:
    [gii]:/checker>sh -x toy.sh + echo in shell part in shell part + /usr/bin/perl -x toy.sh Semicolon seems to be missing at toy.sh line 4. Unquoted string "echo" may clash with future reserved word at toy.sh l +ine 5. syntax error at toy.sh line 5, near "echo " String found where operator expected at toy.sh line 5, near "echo "bac +k in shell "" (Do you need to predeclare echo?) Execution of toy.sh aborted due to compilation errors. FOO= + echo + echo perl said perl said + echo back in shell back in shell
NEW! perl script inside a shell script??
by Anonymous Monk on Jun 27, 2002 at 18:41 UTC
    I need to call a long perl script from a shell program..it needs to be like that, since the shell program is very big. any ideas? i'm new to this stuff,help!!
      (I realize I'm responding to an old post) #! /bin/sh # the shell script can be arbitrarily long echo $SHELL echo line filtered by pearl | perl -x $0 exit # the previous line must not be removed (this is a void in the script as the shell nor perl will execute) # the following must not be removed #! perl # it can also be the full path of perl - the -x only looks for a #! and perl on the line though. # the following perl script must be come last but can be arbitrarily long while (<>) { s/pearl/perl/; }

      (sorry, I didn' know this would line-wrapt)
      (I realize I'm responding to an old post)
      #! /bin/sh

      # the shell script can be arbitrarily long

      echo $SHELL
      echo line filtered by pearl | perl -x $0

      exit
      # the previous line must not be removed

      (this is a void in the script as the shell nor perl will execute)

      # the following must not be removed
      #! perl
      # it can also be the full path of perl - the -x only looks for a #! and perl on the line though.

      # the following perl script must be come last but can be arbitrarily long

      while (<>) {
      s/pearl/perl/;
      }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2024-09-07 20:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.