foreach item $list {if {![regexp $pattern $item]} {lappend results $item}}
if { [catch {exec ssh root@ftpserver find /home/ -type f -mmin -60|egrep -v 'blah|blagh'} x] } {
puts "egrep exited with a non zero exit so no new ftp files"
} else {
exec mail -s 'new ftp files' happygirl1@corp.com,happygirl2@corp.com << $x
}
proc smtp_email {name to subj body} {
set smtp_server 10.0.0.158; # change this to your server.
set my_email me@domain.com; # change this to your email address.
set s [socket $smtp_server 25]
gets $s answer
if {[lindex $answer 0] != 220} {error $answer}
puts $s "MAIL FROM:<$my_email>";flush $s
gets $s answer
if {[lindex $answer 0] != 250} {error $answer}
puts $s "RCPT TO:<$my_email>";flush $s
gets $s answer
if {[lindex $answer 0] != 250} {error $answer}
puts $s DATA;flush $s
gets $s answer
if {[lindex $answer 0] != 354} {error $answer}
puts $s "From: $name <$my_email>"
puts $s "Return-Path: $name <$my_email>"
puts $s "To: $to"
puts $s "Subject: $subj"
puts $s "\n."
flush $s
gets $s answer
if {[lindex $answer 0] != 250} {error $answer}
close $s
}
# I pass in a different name from each caller. e.g.
# smtp_email "Nightly Backup" sysadmin@domain.com "Backup OK" "At [clock format [clock seconds]]"
Wednesday, August 5, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment