[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

[ilug-cal] Perl Scripts for student account



hi all,

    recently noticed a thread about how to read and compose mail offline through shell account and then send the mails composed as soon as connected through shell. Here is how I do it.

for retrieving mail, method prescribed by rajarshi is ok.for composing mail offline I use the following script.

#!/usr/bin/perl

open(OUT,">>/suman/mail.txt");

print OUT "MAIL FROM:suman55\@giascla.vsnl.net.in\n";
print "\nEnter Sender's Address Please\n";
$input=<STDIN>;
chop($input);
#$p=index($input,"\@");

#if ($p >=0) {
#@array1=split(/\@/,$input);
#$first1=$array1[0];
#$second1=$array1[1];
#$one1=join("\\@",$first1,$second1);
#print "$one1\n";
print OUT "RCPT TO:$input\n";
#}



print "Please enter the body of the message\n";
print "Body ends with a line starting with .\n";
print "The last line should contain the . only\n";
print "No other line should contain a leading .\n";
print "Please press ^D after the last line\n";
print OUT "DATA\n";
@ar=<STDIN>;
chop(@ar);
for ($i=0;$i<@ar;$i++) {
$line=$ar[$i];
#$line=<STDIN>;
$position=index($line,"\@");
if ($position >=0) {
@array=split(/\@/,$line);
$first=$array[0];
$second=$array[1];
$one=join("\\@",$first,$second);
#print "$one\n";
print OUT "$one\n";
}
else {
print OUT "$line\n";
}
}
close (OUT);
#open (IN,"/suman/mail.txt");
#$h=<IN>;
#while ( $h ne "") {
#print "$h\n";
#$h=<IN>;
#}
#close(IN);

for sending mail automatically as soon as i am connected, i use the following procedure.

at the menu, give option 3
give the hostname as giascla.vsnl.net.in 25
then press C-A Q to exit minicom without resetting the modem or start another terminal.
use the following script.

#!/usr/bin/perl

#open (RECE,"/dev/modem") || die "Could not read from /dev/modem\n";
open (SEND, ">/dev/modem") || die "Could not write to /dev/modem\n";
open (IN,"/suman/mail.txt");

$r=<IN>;

while ($r ne "") {
print SEND $r;
#for ($i=0;$i<0000;$i++) {
#$t=$i;
#}
$r=<IN>;
}

print "\nMail Complete\n";


at the terminal give the prompt
perl m.pl
it sends the mail and after completing, greets with a message.

no need for cut and paste stuff.
enjoy.
it is valid for any student server.


_________________________________________________

Get Your Free Email At, http://www.rediffmail.com

- --------------------------------------------------------------------
For more information on Linux in India visit http://www.linux-india.org/
Please do not post HTML email to this mailing list.  HTML mails will be
thoroughly ignored and derisively sniggered at in private.

------------------------------