bash and perl

D

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
 
B

Ben Morrow

Quoth David Williams said:
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
#!/bin/bash
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
 
K

krish

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.
 
D

David Williams

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?
 
J

Joost Diepenmaat

David Williams said:
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.
 
C

ccc31807

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
 
J

Jürgen Exner

David Williams said:
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
 
D

David Williams

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top