bash and perl

Discussion in 'Perl Misc' started by David Williams, Feb 18, 2008.

  1. I don't think my first message went through.
    Wondering if there is a way to mix perl and shell scripts?

    Like this:


    #!/usr/bin/perl
    David Williams, Feb 18, 2008
    #1
    1. Advertising

  2. David Williams

    Ben Morrow Guest

    Quoth David Williams <>:
    > I don't think my first message went through.
    > Wondering if there is a way to mix perl and shell scripts?
    >
    > Like this:
    >
    > #!/usr/bin/perl

    <snip>
    > #!/bin/bash

    <snip>
    > I tried this above but Perl did not like it.


    What are you actually trying to achieve? When do you want the shell to
    be executed? You can easily include shell in your Perl script, as a
    heredoc, and then feed it to /bin/bash or anything else...

    Ben
    Ben Morrow, Feb 18, 2008
    #2
    1. Advertising

  3. David Williams

    krish Guest

    On Feb 18, 7:41 am, Ben Morrow <> wrote:
    > Quoth David Williams <>:
    >
    > > I don't think my first message went through.
    > > Wondering if there is a way to mix perl and shell scripts?

    >
    > > Like this:

    >
    > > #!/usr/bin/perl

    > <snip>
    > > #!/bin/bash

    > <snip>
    > > I tried this above but Perl did not like it.

    >
    > What are you actually trying to achieve? When do you want the shell to
    > be executed? You can easily include shell in your Perl script, as a
    > heredoc, and then feed it to /bin/bash or anything else...
    >
    > Ben


    If you want to embed some BASH script inside perl and call it inside
    perl program, the following
    might help.

    #!/usr/bin/perl

    .....
    .....
    {
    open(MYPROG,">bscript.sh") or die "..."
    local $/ ;
    $myprog = <DATA> ;
    print MYPROG $myprog ;
    }
    system("$myprog");
    $ret = $?>>8 ;
    ......
    .....
    __DATA__
    #!/bin/bash

    echo "this is my bash program" ;
    ....
    ....
    ...

    Is this the one you want ?
    Otherwise let me know, what exactly is your requirement.
    krish, Feb 18, 2008
    #3
  4. Hello all,
    I'm just trying to send mail using the mail command.
    I would use perl but sendmail is not running and so
    far all I see in the perl modules is sendmail. is there
    a postfix module?



    --
    David Williams
    Georgia Institute of Technology, Atlanta Georgia, 30332
    Email:
    David Williams, Feb 18, 2008
    #4
  5. David Williams <> writes:

    > Hello all,
    > I'm just trying to send mail using the mail command.
    > I would use perl but sendmail is not running and so
    > far all I see in the perl modules is sendmail.


    MIME::Lite does sendmail and SMTP.

    > is there
    > a postfix module?


    Doesn't postfix speak SMTP?

    ps: You should start a new thread for new issues. Please don't post them
    as replies to an unrelated question.

    --
    Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
    Joost Diepenmaat, Feb 18, 2008
    #5
  6. David Williams

    ccc31807 Guest

    On Feb 18, 8:53 am, David Williams <> wrote:
    > Hello all,
    > I'm just trying to send mail using the mail command.
    > I would use perl but sendmail is not running and so
    > far all I see in the perl modules is sendmail. is there
    > a postfix module?


    The Perl sendmail module doesn't use sendmail. I know it's confusing,
    but you can use Perl sendmail to send mail even on a server that's not
    running sendmail.

    see the documentation for mail::sendmail, a simple platform
    independent mailer.

    CC
    ccc31807, Feb 18, 2008
    #6
  7. David Williams <> wrote:
    >I don't think my first message went through.
    >Wondering if there is a way to mix perl and shell scripts?


    No problem.

    >Like this:


    > #!/usr/bin/perl
    >[...]
    > #!/bin/bash
    >[...]
    >I tried this above but Perl did not like it.


    Well, no, you cannot all of a sudden change the programming language in the
    middle of a program.
    Of course you can always just call a bash script from the Perl script and
    vice versa. Or you can rewrite your bash code in Perl. I don't think there
    is anything you can do in bash that you couldn't do in Perl, even as a
    practical matter, not just theoretical Turing Completeness.

    jue
    Jürgen Exner, Feb 19, 2008
    #7
  8. Okay.
    Sorry to everyone. Apparently, I can just open up
    sendmail directly from perl like

    open(filedesc,"| 'path to sendmail' -t");
    sendmail headers
    ..
    ..
    ..
    ..

    close filedesc;


    Sorry for all of the confusion



    --
    David Williams
    Georgia Institute of Technology, Atlanta Georgia, 30332
    Email:
    David Williams, Feb 22, 2008
    #8
    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. Goblin
    Replies:
    1
    Views:
    8,428
  2. William Park

    (patch for Bash) GTK+2 + Bash

    William Park, Jul 11, 2005, in forum: XML
    Replies:
    3
    Views:
    2,286
    William Park
    Jul 14, 2005
  3. Peter Steele

    bash shell script - perl conversion

    Peter Steele, Apr 2, 2004, in forum: Perl Misc
    Replies:
    1
    Views:
    93
    Paul Lalli
    Apr 2, 2004
  4. Rob Beattie

    perl -e and bash

    Rob Beattie, Apr 8, 2004, in forum: Perl Misc
    Replies:
    7
    Views:
    89
    Sisyphus
    Apr 9, 2004
  5. ecureuil

    with bash : hostname -d - with perl?

    ecureuil, May 25, 2006, in forum: Perl Misc
    Replies:
    10
    Views:
    205
    Dr.Ruud
    May 25, 2006
Loading...

Share This Page