在imap2中获取的结果显示在控制台中 [英] Fetched results in imap2 to display in console

查看:72
本文介绍了在imap2中获取的结果显示在控制台中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我制作了一个脚本,该脚本连接到imap服务器,然后发送不同的消息,以便获得第一封邮件[我只需要第一封邮件]. 当我运行脚本时,没有任何结果,但是当我在终端中键入相同的最后一条命令时,我得到了结果.

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?

我的脚本:

#!/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"

正如我之前所说,当我在终端中键入5 fetch 1 body[]时,我会得到一些输出,但是脚本什么也没显示.有什么想法吗?

As I said before ,when I type 5 fetch 1 body[] in terminal i get some output but the script shows nothing.any ideas?

推荐答案

您的脚本有几个语法错误,我认为您根本没有尝试研究IMAP语法.

Your script has several syntax errors and I do not think you've made any attempt at researching IMAP syntax at all.

send "1 login picard enterprise\r"

这是正确的,只要登录名和密码中不包含空格或其他奇数字符,并且在其中键入\ r时Expect实际发送\ r \ n.

This is correct provided that the login and password don't contain spaces or other odd characters, and that Expect actually sends \r\n when you type \r there.

send "2 list '' '*'\r"

''不是IMAP,IMAP使用"".

'' is not IMAP, IMAP uses "".

send "3  EXAMINE INBOX\r"

在3个之后,您的一个空格太多了.在IMAP中,空格不是幂等的.如果该协议说要使用一个空间,则您必须只使用一个空间,既不能多也不能少.

You have one space too many after the 3. Spaces aren't idempotent in IMAP; if the protocol says to use one space you have to use exactly one, neither more nor less.

send "4 fetch 1 all\r"
send "5 fetch 1 body[]\r"

ALLBODY[]重叠,为什么呢?都发送吗?您可以发送4 FETCH 1 (FLAGS INTERNALDATE BODY[])并获得相同的数据而无需重复.

ALL and BODY[] overlap, why do you send both? You could just send 4 FETCH 1 (FLAGS INTERNALDATE BODY[]) and get the same data without repetition.

这篇关于在imap2中获取的结果显示在控制台中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆