lamb@saddle.UUCP (Richard Lamb) (01/30/91)
Here is a expect/tcl[1] based script Ive been using to snarf incomming MCI mail, convert the From: field into a Internet reply-able format, and stuff it into the UUCP/Internet mail stream. In this way I can integrate MCI-mail into my unix/internet environment. Sending mail TO MCI is not a problem since they provide a gateway with mcimail.com. A permanent "forwarding" arangement FROM MCI appears to be possible on request to MCI using a "Off-Net Registrant (ONR)". Hovever, when I travel MCI-mail can be inexpensively and convieniently accessed; so a temporary forwarding mechanism was important to me. An attempt was made to make the psudo uucp node "mci" look like any other uucp node. Logging information is placed in /usr/spool/uucp/.Log/uucico/mci and ../../.Status/mci so that things like "uustat -m" kinda work. If there is any demand , I could add outgoing UUCP->MCI support also for those that have no internet/usenet conectivity. I assume an error-free link via a 2400 Baud MNP modem (the TB script is included). I use it on a HDB uucp machine (SCO-ODT). If such a script already exists, my apologies (and where is it ! I certainly dont claim mine is the best.) . [1] "expect" is Don Libes interactive script processing program available on uunet. "tcl" is a supporting command language written by John Ousterhout also on uunet. Disclaimer: I neither work for or am associated with MCI. ==============/usr/spool/cron/crontabs/uucp================== 15 * * * * /usr/lib/uucp/mcimail mciname1 mcipass user1@foobar.com > /dev/null 20 * * * * /usr/lib/uucp/mcimail mciname2 mcipass user2@abcu.edu > /dev/null # mci-login-name password who-to-forward-to ==============/usr/lib/uucp/mcimail========================== touch /usr/spool/uucp/.Log/uucico/mci if test -f /usr/spool/uucp/LCK..mci; then exit; fi touch /usr/spool/uucp/LCK..mci cd /usr/lib/uucp SETSTR="set username $1; set password $2; set localto $3;" /u/local/bin/expect -c "$SETSTR" mcimail.exp rm /usr/spool/uucp/LCK..mci ===============/usr/lib/uucp/mcimail.exp===================== #========================================================================= # Copyright XtcN Ltd. 1991 # # All Rights Reserved # # Permission to use, copy, and distribute this software and its # documentation is hereby granted, provided that the above copyright # notice appear in all copies and that no monetary gain be derived # from this software without specific, written prior permission. #========================================================================= # # This is part of the MCI MAIL interface packadge # Do all this as user UUCP # My shells wont do it !/usr/local/bin/expect -f # # THINGS YOU MAY HAVE TO CHANGE # maximum time it would take to "print" a single article in seconds set timemax 1000 # maximum number of messages to read set mailmax 100 # where the uucp spool dir for uucp machine "mci" is set uuspool /usr/spool/uucp/mci # where these mcimail processing files reside set uulib /usr/lib/uucp # where status info will be saved set uustatus /usr/spool/uucp/.Status/mci # where log info will be saved set uulogf /usr/spool/uucp/.Log/uucico/mci # # STUFF THAT COMES IN THE COMMAND LINE # login name and password for user into MCI if ![info exists username] { exit } if ![info exists password] { exit } # who to send the mail to. Can be another machine. if ![info exists localto] { exit } # # set match_max 10000 # Procedures proc failed {} { global localto uustatus uulogf system echo "0 0 000000000 0 `date +%m/%d-%H:%M`_Failed mci" >$uustatus system echo "uucp mci \(`date +%m/%d-%T`\) FAILED \($localto\)" >>$uulogf exit } proc success {} { global localto uustatus uulogf system echo "0 0 000000000 0 `date +%m/%d-%H:%M`_SUCCESSFUL mci" >$uustatus system echo "uucp mci \(`date +%m/%d-%T`\) SUCCEEDED \($localto\)" >>$uulogf } # Login to MCI MAIL # MCI can take a while to start up and log in to avg 20 sec system echo "2 0 000000000 0 `date +%m/%d-%H:%M`_Locked mci" >$uustatus system echo "uucp mci \(`date +%m/%d-%T`\) STARTUP \($localto\)" >>$uulogf set timeout 50 # make the connection to MCI via MNP spawn cu mci2 expect {*2400/REL*} {} timeout failed send \r expect {*name:*} {} timeout failed send $username\r expect {*\r\nPassword:*} {} timeout failed send $password\r expect {*\r\nCommand:*} {} timeout failed system echo "2 0 000000000 0 `date +%m/%d-%H:%M`_Talking mci" >$uustatus system echo "uucp mci \(`date +%m/%d-%T`\) OK \($localto\)" >>$uulogf # Check to see if we have any mail send scan inbox\r expect \ {*INBOX\ is\ empty*} { expect {*\r\nCommand:*} send exit\r expect {*Lost\ Carrier*} system echo "uucp mci \(`date +%m/%d-%T`\) NO MAIL \($localto\)" >>$uulogf success exit } \ {*type\ NO\ to\ stop*} { send no\r expect {*\r\nCommand:*} } \ {*\r\nCommand:*} { } \ timeout failed # Read the MCI mail messages into local files mail1.in mail2.in .... # Careful. This is how long we will wait till the "print" is finished set timeout $timemax for {set i 1} {$i < $mailmax} {set i [expr $i+1]} { log_user 0 exec rm -f $uuspool/mail$i.in log_file -a $uuspool/mail$i.in send print $i\r expect \ {*\r\nCommand:*} { log_file log_user 1 system echo "uucp mci \(`date +%m/%d-%T`\) REMOTE REQUESTED \(mail$i.in\)" >>$uulogf } \ {*\r\nThere\ is\ no\ message\ numbered*} { log_file log_user 1 send exit\r expect {*Lost\ Carrier*} break } \ timeout failed } system echo "2 0 000000000 0 `date +%m/%d-%H:%M`_SUCCESSFUL-CALL mci" >$uustatus system echo "uucp mci \(`date +%m/%d-%T`\) STARTUP MCI-TO-INTERNET" >>$uulogf # Convert MCI format mail to internet format set mailmax [expr $i] for {set i 1} {$i < $mailmax} {set i [expr $i+1]} { system $uulib/mci2internet $localto $uuspool <$uuspool/mail$i.in } success # Have uucp deliver them to the local users system nohup /usr/lib/uucp/uuxqt -smci >/dev/null & # delete them if you desire # exec rm -f $uuspool/mail*.in exit ====================/usr/lib/uucp/mci2internet======================= #========================================================================= # Copyright XtcN Ltd. 1991 # # All Rights Reserved # # Permission to use, copy, and distribute this software and its # documentation is hereby granted, provided that the above copyright # notice appear in all copies and that no monetary gain be derived # from this software without specific, written prior permission. #========================================================================= # # This is part of the MCI MAIL interface packadge # This is all run as user UUCP cd "$2" # umi local_user <mci_mail_file #BASS=`echo $1 | cut -d"." -f1` DFILE="D.$BASS$$" XFILE="X.$BASS$$" LOCALTO="$1" #========================== # delete the first 2 lines "print" line line >/dev/null line >/dev/null # Save it elsewhere if it doesnt look like an MCI mail file MDATE=`line | tr -d "\015"` TESTDATE=`echo $MDATE | cut -d" " -f1` if test "Date:" != "$TESTDATE"; then echo "======Junk==========" >>junked; cat >>junked; exit; fi # To make uuxqt-submit-sendmail-rmail happy echo "From uucp" >$DFILE # Dump the Date: line echo "$MDATE" >>$DFILE # Re-write the From: line to internet format FROM=`line | tr -d "\015"` UNAME=`echo $FROM | cut -d" " -f2-3` MCIID=`echo $FROM | cut -d" " -f5-100` if test -n "$MCIID"; then ADDR1=`echo $MCIID | cut -d" " -f3 | sed s/-//`; ADDR1="000$ADDR1@mcimail.com"; line >/dev/null; else EMS=`line | tr -d "\015"`; if test -n "`echo $EMS | grep \^EMS:`"; then ETYPE=`echo $EMS | cut -d" " -f2`; ADDR1=""; while MBX=`line | tr -d "\015"`;test -n "`echo $MBX | grep \^MBX:`"; do ADDR1=$ADDR1`echo $MBX | cut -d" " -f2`" "; done else ADDR1="Unknown"; fi fi echo "From: $UNAME <$ADDR1>" >>$DFILE # Cache the TO: and CC: lines untill Subject: is reached echo "" >tmpii while TOLINE=`line | tr -d "\015"`; test -z "`echo $TOLINE | grep \^Subject:`"; do echo "$TOLINE" >>tmpii; done # Dump the local To: field echo "To: $LOCALTO" >>$DFILE # Dump the subject SUBJECT="$TOLINE" echo "$SUBJECT" >>$DFILE # Dump the cached TO: and CC: lines cat tmpii >>$DFILE; rm tmpii # Dump the rest of the article tr -d "\015" | sed s/\^Command.*// >>$DFILE #========================== echo "U postmaster xtcn.com R postmaster@xtcn.com F $DFILE I $DFILE C rmail $LOCALTO " > $XFILE chown uucp $DFILE $XFILE chgrp other $DFILE $XFILE chmod a-rwx $DFILE $XFILE chmod u+rw $DFILE $XFILE ====================/usr/lib/uucp/Systems================== # for MCI mail mci Any ACU2400 2400 18004566245 mci2 Any ACUMNP 2400 18003331818 ====================/usr/lib/uucp/Devices================== ACUMNP ttyFM00 - 2400 tbmnp ====================/usr/lib/uucp/Dialers================== tbmnp =W-, "" A\pA\pA\pA\pA\pTQ0E0S0=0\r\c OK ATS66=1s50=0s111=0s95=1DT\T CONNECT-\c-CONNECT &tbmnp =,-, "" +++\dATQ0H OK ATE0 OK ATS66=0S50=0S111=255S95=0S0=1Q1 ==========End of files================Hope its useful================== Rick -- ############################################################################ # _ /| | Richard Lamb Internet: lamb@lids.mit.edu # # \'o.O' | MCI Mail: 423-9516 Telex: 6504239516 # # =(___)= | SnailNet: |XtcN Ltd | |XtcN Ltd |# # U | |16 Cochituate St.| OR |4425 Butterworth Pl. N.W.|# # Ack! Phht! | |Natick MA 01760 | |Washington D.C. 20016 |# # | |Voice:5086552960 | |Voice:2023633661 |# ############################################################################