File: bbmailparsefm.pl

package info (click to toggle)
bbmail 0.9.3-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,024 kB
  • sloc: sh: 8,381; cpp: 2,392; makefile: 27; perl: 26
file content (37 lines) | stat: -rwxr-xr-x 660 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl 
# 
# Quickie script to parse fetchmail -c output
# (IMAP proto) for use with bbmail
# 
# Typical fetchmail output is:
# "X messages (Y seen) for foo-user at bar-host."
# 
# wcb 4/15/2000
# 
$newmail = 0;
$totalmail = 0;
$line = <STDIN>;
if ( $line =~ /^(\d+)\s+message/i )
	{
	$totalmail = $1;
	if ( $line =~ /\s+\((\d+)\s+seen\)/i )
		{
		$newmail = $totalmail - $1;
		}
	else
		{
		$newmail = $totalmail;
		}
	}
elsif ( $line =~ / no mail/i )
	{
	$newmail = 0;
	$totalmail = 0;
	} 
else		# not getting expected fetchmail output,
		# so report error 
	{
	$newmail = "error";
	$totalmail = "error";
	}
print ($newmail, " ", $totalmail, "\n");