Linux Training

Linux training for private, public & voluntary sector.

0793 572 8612

City LinUX sample scripts - msg_del


# $Id: msg_del,v 1.1 2015/03/30 10:29:50 fulford Exp $
# $Source: /src/merlin/usr/local/etc/RCS/msg_del,v $
# $Revision: 1.1 $
# Author C W Fulford.
# Copyright 2014 (c) C W Fulford.
# Licensed for public use under the LGPL, .
# For assistance contact fulford@fulford.net 0709 229 5385
########################################################################
  log_user 0    ;# hide interaction, i.e. do not display to stdout
  set timeout 12
  match_max 100000

  set srvr  [lindex $argv 0]
  set proto [lindex $argv 1]
  set user  [lindex $argv 2]
  set mbox  [lindex $argv 3]
  set pass  [lindex $argv 4]
  set del   [lindex $argv 5]

  if { $proto == "ssl" } {
	set port 993
	spawn  openssl s_client -connect  $srvr:$port -crlf
  } else {
	set port 143
  	spawn telnet $srvr $port
  }
  expect {
    timeout {puts stderr "timeout while connecting to $srvr"; exit 1}
    "not open" {puts stderr "cannot connect" ;puts stout "-1";exit 1}
    "* OK"
  }
  send "a1 login $user $pass\r"
  expect {
    "* OK" 
  }
  send "a2 SELECT $mbox\r"
  expect "a2 OK"
#  send "a3 FETCH 1:100 (FLAGS RFC822.HEADER.LINES (DATE FROM))\r"
#  expect "a3 OK"
  send "a4 STORE 1:$del +FLAGS (\\Deleted)\r"
  expect "* OK"
  send "a5 EXPUNGE\r"
  expect "a5 OK"
  send "a6 examine $mbox\r"
  expect "a6 OK"
  send "a7 logout\r"

  

######################################################################
# This program is free software: you can redistribute it and or      #
# modify it under the terms of the Lesser GNU General Public License #
# as published by the Free Software Foundation, either version 3 of  #
# the License, or (at your option) any later version.                #
#                                                                    #
# This program is distributed in the hope that it will be useful,    #
# but WITHOUT ANY WARRANTY; without even the implied warranty of     #    
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      #
# GNU General Public License for more details.                       #
#                                                                    # 
# A copy of the Lesser GNU General Public License and the GNU        #
# General Public License is available at                             #
# <http://www.gnu.org/licenses/>.                                    #
######################################################################

The layout and associated style sheets for this page are taken from the World Wide Web Consortium and used here under the W3C software licence.