gawk 收取邮件测试
时间:2007-03-29 来源:awk就是awp加ak
echo |awk '
BEGIN {
Service = "/inet/tcp/0/pop.163.com/110"
Service |& getline;
print;
print "USER user" |& Service
Service |& getline;
print;
print "PASS pass" |& Service
Service |& getline;
print;
print "LIST" |& Service
while ((Service |& getline line) > 0 && !(line~/^\./) && ++mailCount) print line;
mailCount--;
if (mailCount > 6){
print "RETR 7" |& Service
while ((Service |& getline line) > 0 && !(line~/^\./)) print line;
}
print "QUIT" |& Service
close(Service)
}' 1、Service = "/inet/tcp/0/mail.163.com/110"
gawk 进行network通讯指定格式,/inet/<tcp|udp|raw>/<0|local_port>/<remote_host>/<remote_port>
2、(Service |& getline line) > 0
判断是否能正常从 Service 通过管道读取一行到 line,其中Service 也可以是可执行的任何文件
3、print "QUIT" |& Service
通过管道向 Service 输出
4、close(Service)
关闭文件
BEGIN {
Service = "/inet/tcp/0/pop.163.com/110"
Service |& getline;
print;
print "USER user" |& Service
Service |& getline;
print;
print "PASS pass" |& Service
Service |& getline;
print;
print "LIST" |& Service
while ((Service |& getline line) > 0 && !(line~/^\./) && ++mailCount) print line;
mailCount--;
if (mailCount > 6){
print "RETR 7" |& Service
while ((Service |& getline line) > 0 && !(line~/^\./)) print line;
}
print "QUIT" |& Service
close(Service)
}' 1、Service = "/inet/tcp/0/mail.163.com/110"
gawk 进行network通讯指定格式,/inet/<tcp|udp|raw>/<0|local_port>/<remote_host>/<remote_port>
2、(Service |& getline line) > 0
判断是否能正常从 Service 通过管道读取一行到 line,其中Service 也可以是可执行的任何文件
3、print "QUIT" |& Service
通过管道向 Service 输出
4、close(Service)
关闭文件
相关阅读 更多 +