sending via smtp (code included)

sigzero_at_gmail.com
Date: 03/07/05


Date: 7 Mar 2005 05:47:48 -0800

I have a script that sends me a log file via smtp. The log file is
generally 65-75k. If I create a log file with just the word "test" in
it the script works fine. When I try it against the actual log file I
get:

error flushing "sock672": invalid argument
    while executing
"flush $channel"
    (procedure "mime::copymessageaux" line 178)
    invoked from within
"mime::copymessageaux $token $channel "
    invoked from within
"::mime::copymessage $part $state(sd) "
    invoked from within
"wtextaux $token $part "
    invoked from within
"smtp::sendmessage $token -recipients $recipient -servers
$email_server"
    (procedure "send_simple_message" line 8)
    invoked from within

Any ideas?

I am using:
ActiveState Tcl 8.4.9
Windows 2000 Server

Robert

No Laughing Beyond This Point! :-)
=======================================
# Created: January 17, 2005
#
# Purpose: This script will run the Mincom Ellipse MSQUPD.EXE
# to update the Ellipse popups database. It will then
# email the msqupd.log file to the admin for further action.
#
# Version: 0.6

# version 0.01 initial skeleton
# version 0.02 added some pseudo code to get the flow of the script
# version 0.03 added some real code to do stuff
# version 0.04 everything but the archiving
# version 0.05 added the deleting of the Ellipse cache directory
# version 0.06 added the deleting of olf log files

# If the day is Sunday, get rid of log files

puts "========================"
puts " Deleting Old Log Files "
puts "========================\n"
set theDay [clock format [clock scan now] -format %u]
set logDir [file join {M:\Path\To\ParadoxMaster}]

if {$theDay == 7} {
    foreach logFiles [glob -nocomplain $logDir/msqupd.log*] {
        file delete -force $logFiles
    }
}

puts "======================"
puts " Deleting Users CACHE "
puts "======================\n"
set mimsCache "MIMS Cache"
foreach cacheDir [glob -nocomplain M:/users/*/Ellipse/temp/$mimsCache]
{
    file delete -force $cacheDir
}

set msqupd [file join {M:\\Path\To\msqupd.exe}]
set dist1 "elldev"

puts "==================="
puts " Refreshing ELLDEV "
puts "==================="
exec $msqupd $dist1

proc send_simple_message {recipient email_server subject body} {
    package require smtp
    package require mime

    set token [mime::initialize -canonical text/plain -string $body]

    mime::setheader $token Subject $subject
    smtp::sendmessage $token -recipients $recipient -servers
$email_server
    mime::finalize $token
}

set logfile [file join {M:\Path\To\msqupd.log}]
set channel [open $logfile r]
set msgBody [read $channel]

set uname $::env(COMPUTERNAME)
set subText "Popup Refresh Report"
set textDate [clock format [clock scan now] -format %Y%m%d]
set msgSubj "$uname: $subText $textDate"

# this line has been changed to mask the info
send_simple_message me@me.com smtp.server.name $msgSubj $msgBody

close $channel

# archive the file
set suffix [clock format [clock scan now] -format %Y%m%d%H%M%S]
file rename $logfile $logfile.$suffix

exit



Relevant Pages

  • Re: unix shell script ignores exit when in function that is piped to tee
    ... > I thought calling a function within a script did NOT create sub-shells. ... is going to be able to alter the log file to cover up any inappropriate ... entry in the log to the previous entry. ... The easiest way to use crypt to ...
    (comp.unix.shell)
  • The necessity of Setting Objects to Nothing
    ... But what happens when you've got a script that is running as ... Dim Servers, List, strComputer ... Set Folder = objFSO.GetFolder ... '~~~ Write the results of the number of users query to a log file. ...
    (microsoft.public.scripting.vbscript)
  • Re: CSVDE Importing
    ... > specify the log file path via the -j option. ... CSVDE imports can only be used to create new users ... Unfortunately, the syntax is a bit more involved than a simple csv file, ... which makes it a little more difficult to manage its content via script. ...
    (microsoft.public.windows.server.scripting)
  • Re: CSVDE Importing
    ... > specify the log file path via the -j option. ... CSVDE imports can only be used to create new users ... Unfortunately, the syntax is a bit more involved than a simple csv file, ... which makes it a little more difficult to manage its content via script. ...
    (microsoft.public.windows.server.active_directory)
  • Re: Recurse issue - 2nd try
    ... My script simply stops short. ... However, when I view the log file, it is missing several files. ... > is your script hanging or does it complete but somehow misses some folders? ... >> Dim sLogFile ...
    (microsoft.public.scripting.vbscript)