aboutsummaryrefslogtreecommitdiffstats
path: root/mxget.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1997-08-04 04:10:40 +0000
committerEric S. Raymond <esr@thyrsus.com>1997-08-04 04:10:40 +0000
commit4fe1884292376b223d3dee76b194a47e90323541 (patch)
treeb47d68765ace204afe94e2fa14576ba6bb42566b /mxget.c
parentdcb63c343a411c59257407b07f08c2210e236c80 (diff)
downloadfetchmail-4fe1884292376b223d3dee76b194a47e90323541.tar.gz
fetchmail-4fe1884292376b223d3dee76b194a47e90323541.tar.bz2
fetchmail-4fe1884292376b223d3dee76b194a47e90323541.zip
Added `postconnect'.
svn path=/trunk/; revision=1226
Diffstat (limited to 'mxget.c')
0 files changed, 0 insertions, 0 deletions
} /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#!/usr/bin/expect -f

# MySQL database connection settings
set CRDB_host     localhost
set CRDB_DB       test
set CRDB_username root
set CRDB_password root

# set eiter one to 1 for verbose output
log_user 0
set comments 0

package require mysqltcl

# connect to MySQL database
set handle [::mysql::connect -host $CRDB_host -user $CRDB_username -password $CRDB_password]

# get server/usernames to clean up
set userlist [::mysql::sel $handle "SELECT UserID, server, username, password, retaindays from $CRDB_DB.fetchmail_user" -flatlist]

# loop through all users in database
foreach {userid server username password days} $userlist {
  if {$comments==1} { send_user "\r\nWorking on accound #$userid\r\n*******************************\r\n" }
  eval spawn telnet -l fetchmail_cleanup $server 110
  expect "ready"
  send "USER $username\r"
  expect "password"
  send "PASS $password\r"
  expect "OK"
  send "STAT\r"
  expect "+OK "
  expect -re "\[0-9]* "
  set anz $expect_out(0,string)
  if {$comments==1} { send_user "message count: $anz \r\n" }
  set i 0
  while { $i < $anz } {
    incr i
    send "UIDL $i\r"
    expect -re "\\\+OK $i \(.*\)\r"
    set uid $expect_out(1,string)
    ::mysql::exec $handle "insert ignore into $CRDB_DB.fetchmail values ($userid,'$uid',now());"
    set age [::mysql::sel $handle "SELECT DATEDIFF(now(),Fetchdate) from $CRDB_DB.fetchmail where UserID=$userid and UID='$uid'" -list]
    if {$comments==1} { send_user "Message #$i: UID: $uid , age: $age \r\n" }
    if {$age > $days} {
      send "DELE $i\r"
      expect "deleted"
      if {$comments==1} { send_user "Message $i deleted.\r\n" }
    }
  }
  send "quit\r"
  expect "signing off"
  ::mysql::exec $handle "delete from $CRDB_DB.fetchmail where DATEDIFF(now(),Fetchdate)>($days*2) and UserID=$userid;"
}
::mysql::close $handle
exit