CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
does this works?

 



xter74
Novice

Oct 17, 2002, 11:20 PM

Post #1 of 7 (753 views)
does this works? Can't Post

hi gurus,

does the following open and read the file???

$filename ='filepath';
open(THATFILE, "$filename") || die "cannot open $filename: $!";
while (<THATFILE>)
{
$_ = $DATA;
}

need to get some scripts to open/read contents of the txt file and mail it.

thanks a lot for helping.


kelkel
Novice

Oct 17, 2002, 11:49 PM

Post #2 of 7 (747 views)
Re: [xter74] does this works? [In reply to] Can't Post

it'll work, but i do not understand why you did : $_ = $DATA;


xter74
Novice

Oct 18, 2002, 12:01 AM

Post #3 of 7 (744 views)
Re: [kelkel] does this works? [In reply to] Can't Post

i need to pass the data to the smtp which writes the data as a content of a msg.

print $remote $DATA;

if not, how can i do i? when i run the scripts the content of the files are not sent... Unsure

please help...


kelkel
Novice

Oct 18, 2002, 12:41 AM

Post #4 of 7 (742 views)
Re: [xter74] does this works? [In reply to] Can't Post

so you mean you have another script to do your emails?


xter74
Novice

Oct 18, 2002, 12:53 AM

Post #5 of 7 (740 views)
Re: [kelkel] does this works? [In reply to] Can't Post

here's my rountine....really appreciate all the help given.... Smile

**********************************************************
$filename = 'E:/Webs/blt.sgp.hp.com/share/cgi-bin/mail.log';
open(THATFILE, "filename") || die "cannot open $filename: $!";
while (<THATFILE>)
{
$_ = $DATA;

}

open LOG, '>> E:/Webs/blt.sgp.hp.com/share/cgi-bin/smtp.log' or die "Cannot open file";
print LOG "\n===============================================\n";
print LOG scalar(localtime), " Started log.\n";

use IO::Socket;

$SMTP_SERVER="ctss21.sgp.hp.com";

$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => "$SMTP_SERVER",
PeerPort => "smtp(25)",
) || die "cannot connect to SMTP port on $SMTP_SERVER\n";

$remote->autoflush(1);

$inline = <$remote>;
if( $inline !~ /^220/ ) {
print LOG "Didn't get 220 response: $inline";
return;
}
print LOG $inline;

print $remote "HELO $SMTP_SERVER\n";
$inline = <$remote>;
if( $inline !~ /^250/ ) {
print LOG "Didn't get 250 response at HELO: $inline";
return;
}
print LOG "$inline";

print $remote "MAIL From: ap-blt_support\@hp.com\n";
$inline = <$remote>;
if( $inline !~ /^250/ ) {
print LOG "Didn't get 250 response at MAIL: $inline";
return;
}
print LOG "$inline";

print "<br>sending: ", "RCPT To: $dst_addr\n <BR>";
print $remote "RCPT To: arsystem\@uspsgn01.sgp.hp.com \n";
$inline = <$remote>;
if( $inline !~ /^250/ ) {
print LOG "Didn't get 250 response at RCPT: $inline";
return;
}
print LOG "$inline";

print $remote "DATA\n";
$inline = <$remote>;
if( $inline !~ /^354/ ) {
print LOG "Didn't get 354 response at DATA: $inline";
return;
}
print LOG "$inline";
print "\n============>$inline";

print $remote $DATA; ### <<---- THIS IS THE LINE THAT WRITE IN THE MSG BODY
print $remote "\n.\n";

$inline = <$remote>;
print LOG $inline;

print $remote "QUIT\n";
$inline = <$remote>;
print LOG $inline;
}
close(THATFILE) || die "can't close $file: $!";
}


thodi
stranger

Oct 18, 2002, 3:16 AM

Post #6 of 7 (734 views)
Re: [xter74] does this works? [In reply to] Can't Post

Instead of

Code
while (<BLA>) { 
$_ = $DATA; # Overwrite input from file with $DATA
}

you probably want something like

Code
while (<BLA>) { 
$DATA .= $_; # Append input from file to $DATA
}

You also want to use 'use strict;' and 'perl -w' in your scripts from now on, if you don't do so already.


xter74
Novice

Oct 20, 2002, 11:40 PM

Post #7 of 7 (715 views)
Re: [thodi] does this works? [In reply to] Can't Post

thanks and it's working.... BlushLaughSly

now i have to customize the form, hopes it's doesn't affect the performace...

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives