Am Samstag, 4. Juni 2005 07.15 schrieb Anish Kumar K:
> yeah this isfine. But In the Program I have given like
>
> my $sendmailPath=PATH WHERE IT IS INSTALLED.
>
> In the perl program itself I need to finfd it out
>
> As I don;t want to do it everytime I change it to a new server...
>
> Anish

Hi

One way you could do it:

Set the $sendmailPath in a BEGIN block after detecting the OS the program is 
running on. Something like

BEGIN {
 our $sendmail;
 if ($^O eq 'linux') {
  $sendmail='/usr/sbin/sendmail';
 }
 elsif ($^O eq ....) {
  ....
 }
}

if there are more than one possibility on a single plattform, you could 
additionaly use file test operators to find out if a certain file is present 
and executable.


The use of a configfile with the path to the sendmail binary would be another 
way.

Eventually you want to check one of the Mail modules on search.cpan.org.


joe

> ----- Original Message -----
> From: "Chris Devers" <[EMAIL PROTECTED]>
> To: "Anish Kumar K" <[EMAIL PROTECTED]>
> Cc: "Perl Beginners List" <beginners@perl.org>
> Sent: Saturday, June 04, 2005 10:39 AM
> Subject: Re: How to get the sendmail path
>
> > On Sat, 4 Jun 2005, Anish Kumar K wrote:
> > > Isn't there a easy way [to find sendmail] [question-mark]
> >
> > If you're on a Unix-ish platform, and the sendmail program is installed
> > somewhere in your $PATH, the `which` command can help. For instance:
> >
> >     $ which sendmail
> >     /usr/sbin/sendmail
> >     $
> >
> > This is on OSX. It can be other places on other platforms.
> >
> > If it isn't in your $PATH, then the `locate` command may help. Chances
> > are, it's going to be in a directory no deeper than three or four levels
> > down, so we can use `grep -v` to exclude deeper paths:
> >
> >     $ locate sendmail | grep -v '/.*/.*/.*/.*/'
> >     /Users/cdevers/bin/update_sendmail
> >     /usr/sbin/sendmail
> >     $
> >
> > This turns it up again, along with a false hit in my home directory.
> > Chances are you'll get similiar false hits, but hopefully the real one
> > will be clear enough.
> >
> > If you don't have the `locate` database on your system, you're going to
> > have to walk the while filesystem, using something like `find`. Here's
> > one way to do it, but it will be very, very, very slow:
> >
> >     $ find / -type f | grep -v '/.*/.*/.*/.*/'
> >
> > The output from this should be similar to what `locate` would have; with
> > luck you'll see it in a folder like /usr/lib, /usr/libexec, /usr/sbin,
> > /usr/local/bin, /opt/bin, et cetera.
> >
> > Good luck!
> >
> >
> > --
> > Chris Devers

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to