I have made a script that connects to a imap server and then sends different messages,in order ot get the first mail[i only need the first one]. When I run the script I get no results but when i type the same last command in the terminal I get a result.
Any idea how to fix this?
MY script:
#!/usr/bin/expect
#!/bin/bash
set password 'ent'
spawn telnet host imap2
send "1 login picard enterprise\r"
send "2 list '' '*'\r"
expect "*"
send "3 EXAMINE INBOX\r"
send "4 fetch 1 all\r"
send "5 fetch 1 body[]\r"
As I said before ,when I type 5 fetch 1 body[]
in terminal i get some output but the script shows nothing.any ideas?
A001 login ...
instead of1 login ...
) to allow script to wait for command completion. Could you trysend "A005 FETCH 1 BODY[]\r\n"
expect "A005"
– Allcotexcept
you can use theimap4
package for Tcl (expect
scripts are just Tcl code): docs.activestate.com/activetcl/8.4/tcllib/imap4/…. You will need to install Tcllib if you don't have it already installed but as a bonus you could also get better security by using TLS (see the top of the page I've linked to). – Isaiasisak