Home: Perl Programming Help: Intermediate:
server variables



Zeke_D
Deleted

Nov 2, 2000, 6:59 PM


Views: 1138
server variables

I am trying to make my script easier to move from server to server. Here is what i have so far:
<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>


$cgiurl = $ENV{'SCRIPT_NAME'};
$dataurl = `pwd`;
@mailprog = `whereis sendmail`;
foreach $mail_prog (@mailprog) {
$mail_prog =~ s/\s+\S+\.\S+//gi;
($header, $mailprog) = split (/\s/,$mail_prog);
}
</pre><HR></BLOCKQUOTE>
Everything is working on my server. but my question is about sendmail. "whereis sendmail" gives an output like this:

sendmail: usr/sbin/sendmail etc/sendmail.cw usr/lib/sendmail

is this a pretty much standard output?
i split it by spaces $header being "sendmail:" and $mailprog being "/usr/sbin/sendmail"
i pretty much ignored everything else.... any ideas/suggestions/comments?


sleuth
Enthusiast / Moderator

Nov 2, 2000, 7:50 PM


Views: 1138
Re: server variables

 
Yes that is correct,

$mailprog = `whereis sendmail`;
($tmp, $path, $path2, $path3)=split(/\s/, $mailprog);
print "$path";

Also will get you the first given path. The three paths all are different places sendmail is on your server. I got the same result.

Sleuth


Zeke_D
Deleted

Nov 2, 2000, 8:00 PM


Views: 1138
Re: server variables

is it neccisary to get all the other paths?

$mail_prog =~ s/\s+\S+\.\S+//gi;
goes ahead and 'ignores' a variable if it contains a period ".", so only the actual paths are loked at, would there be any other reason to keep the other locations?


sleuth
Enthusiast / Moderator

Nov 3, 2000, 1:54 AM


Views: 1138
Re: server variables

 
I don't think so,

The first one that comes up, since it's all given by the server, it will always work. I'd use the first path given by the server.

Sleuth