SlideShare a Scribd company logo
#!/bin/bash
# Tue Feb 17 17:36:38 EST 2004
# NAME: pop3stat
# Copyright 2004, Chris F.A. Johnson
# Released under the terms of the GNU General Public License
# check POP3 server for e-mail
## set these variables to appropriate values
pop=pop.your-isp.com
user=$USER
pass=password
image=$HOME/mail.png
## or put them into the config file
configfile=$HOME/.pop3statrc
pop3stat() {
exec 3<>/dev/tcp/$pop/110
popcmd user $user || return 1
popcmd pass $pass || return 2
popcmd stat || return 3
popcmd quit || return 4
}
popcmd() {
local IFS=${IFS}$'r'
cmd=$*
echo $cmd >&3
read ok num x <&3
[ $verbose -ge 1 ] && printf "%sn" "$1: $ok $num $x"
[ "$ok" = "+OK" ]
}
popupicon() {
set -- $(ps awwwxo user,pid,command | grep "$USER.*[m]ail-notify.*$image")
[ -n "$2" ] && kill $2
[ $num -gt 0 ] && {
display -geometry +1+1 -name mail-notify -comment "$num" $image &
}
}
[ -s "$configfile" ] && . "$configfile"
verbose=0
while getopts vc: var
do
case $var in
c) configfile=$OPTARG ;;
v) verbose=$(( $verbose + 1 )) ;;
esac
done
shift $(( $OPTIND - 1 ))
pop3stat || { echo "popcmd "$cmd" failed"; exit 5; }
case ${1:-t} in
g) popupicon ;;
t) [ $num -eq 1 ] && _PL= || _PL=s
echo "You have $num message$_PL"
;;
esac

More Related Content

What's hot

Basic command for linux
Basic command for linuxBasic command for linux
Basic command for linux
gt0ne
 
Unix Programming with Perl
Unix Programming with PerlUnix Programming with Perl
Unix Programming with Perl
Kazuho Oku
 

What's hot (20)

01 linux basics
01 linux basics01 linux basics
01 linux basics
 
Basics of unix
Basics of unixBasics of unix
Basics of unix
 
Clojure + MongoDB on Heroku
Clojure + MongoDB on HerokuClojure + MongoDB on Heroku
Clojure + MongoDB on Heroku
 
NUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline TutorialNUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline Tutorial
 
Raspberry pi Part 4
Raspberry pi Part 4Raspberry pi Part 4
Raspberry pi Part 4
 
Linux Command Line
Linux Command LineLinux Command Line
Linux Command Line
 
Rc - The Plan 9 Shell
Rc - The Plan 9 ShellRc - The Plan 9 Shell
Rc - The Plan 9 Shell
 
Cuda cluster
Cuda clusterCuda cluster
Cuda cluster
 
Development and practical use of CLI in perl 6
Development and practical use of CLI in perl 6Development and practical use of CLI in perl 6
Development and practical use of CLI in perl 6
 
Workshop programs
Workshop programsWorkshop programs
Workshop programs
 
Sistemas operacionais 13
Sistemas operacionais 13Sistemas operacionais 13
Sistemas operacionais 13
 
Unix 5 en
Unix 5 enUnix 5 en
Unix 5 en
 
Basic command for linux
Basic command for linuxBasic command for linux
Basic command for linux
 
Bash script (mask off remix)
Bash script (mask off remix)Bash script (mask off remix)
Bash script (mask off remix)
 
Comets notes
Comets notesComets notes
Comets notes
 
Crystal Rocks
Crystal RocksCrystal Rocks
Crystal Rocks
 
Andrey Listochkin "Everybody stand back! I know regular expressions"
Andrey Listochkin "Everybody stand back! I know regular expressions"Andrey Listochkin "Everybody stand back! I know regular expressions"
Andrey Listochkin "Everybody stand back! I know regular expressions"
 
Unix Programming with Perl
Unix Programming with PerlUnix Programming with Perl
Unix Programming with Perl
 
Using the Power to Prove
Using the Power to ProveUsing the Power to Prove
Using the Power to Prove
 
Tgh.pl
Tgh.plTgh.pl
Tgh.pl
 

Viewers also liked

GaryZ IT Technology Specialist
GaryZ IT Technology SpecialistGaryZ IT Technology Specialist
GaryZ IT Technology Specialist
Gary Zimtbaum
 
Menu func-sh(1)
Menu func-sh(1)Menu func-sh(1)
Menu func-sh(1)
Ben Pope
 
Menu func-sh
Menu func-shMenu func-sh
Menu func-sh
Ben Pope
 
Programming collaborative-ref
Programming collaborative-refProgramming collaborative-ref
Programming collaborative-ref
Ben Pope
 
An a z index of the bash commands
An a z index of the bash commandsAn a z index of the bash commands
An a z index of the bash commands
Ben Pope
 
An a z index of windows power shell commandss
An a z index of windows power shell commandssAn a z index of windows power shell commandss
An a z index of windows power shell commandss
Ben Pope
 
Compound var
Compound varCompound var
Compound var
Ben Pope
 
Xz file-format-1.0.4
Xz file-format-1.0.4Xz file-format-1.0.4
Xz file-format-1.0.4
Ben Pope
 
Applecmdlista zs
Applecmdlista zsApplecmdlista zs
Applecmdlista zs
Ben Pope
 
Getfilestruct zbksh(1)
Getfilestruct zbksh(1)Getfilestruct zbksh(1)
Getfilestruct zbksh(1)
Ben Pope
 

Viewers also liked (14)

GaryZ IT Technology Specialist
GaryZ IT Technology SpecialistGaryZ IT Technology Specialist
GaryZ IT Technology Specialist
 
Cpsh sh
Cpsh shCpsh sh
Cpsh sh
 
Menu func-sh(1)
Menu func-sh(1)Menu func-sh(1)
Menu func-sh(1)
 
Menu func-sh
Menu func-shMenu func-sh
Menu func-sh
 
Phdel sh
Phdel shPhdel sh
Phdel sh
 
Phadd sh
Phadd shPhadd sh
Phadd sh
 
Luhn sh
Luhn shLuhn sh
Luhn sh
 
Programming collaborative-ref
Programming collaborative-refProgramming collaborative-ref
Programming collaborative-ref
 
An a z index of the bash commands
An a z index of the bash commandsAn a z index of the bash commands
An a z index of the bash commands
 
An a z index of windows power shell commandss
An a z index of windows power shell commandssAn a z index of windows power shell commandss
An a z index of windows power shell commandss
 
Compound var
Compound varCompound var
Compound var
 
Xz file-format-1.0.4
Xz file-format-1.0.4Xz file-format-1.0.4
Xz file-format-1.0.4
 
Applecmdlista zs
Applecmdlista zsApplecmdlista zs
Applecmdlista zs
 
Getfilestruct zbksh(1)
Getfilestruct zbksh(1)Getfilestruct zbksh(1)
Getfilestruct zbksh(1)
 

Similar to Pop3stat sh

Beautiful PHP CLI Scripts
Beautiful PHP CLI ScriptsBeautiful PHP CLI Scripts
Beautiful PHP CLI Scripts
Jesse Donat
 
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaaShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ewout2
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
Lin Yo-An
 

Similar to Pop3stat sh (20)

Pop3ck sh
Pop3ck shPop3ck sh
Pop3ck sh
 
Beautiful PHP CLI Scripts
Beautiful PHP CLI ScriptsBeautiful PHP CLI Scripts
Beautiful PHP CLI Scripts
 
BASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic InterpolationBASH Variables Part 1: Basic Interpolation
BASH Variables Part 1: Basic Interpolation
 
Module 03 Programming on Linux
Module 03 Programming on LinuxModule 03 Programming on Linux
Module 03 Programming on Linux
 
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaaShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
ShellAdvanced aaäaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Php functions
Php functionsPhp functions
Php functions
 
Bash Geekcamp
Bash GeekcampBash Geekcamp
Bash Geekcamp
 
Bouncingballs sh
Bouncingballs shBouncingballs sh
Bouncingballs sh
 
serverstats
serverstatsserverstats
serverstats
 
Functional Structures in PHP
Functional Structures in PHPFunctional Structures in PHP
Functional Structures in PHP
 
Really useful linux commands
Really useful linux commandsReally useful linux commands
Really useful linux commands
 
Perl.Hacks.On.Vim
Perl.Hacks.On.VimPerl.Hacks.On.Vim
Perl.Hacks.On.Vim
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
os lab assignment.pdf
os lab assignment.pdfos lab assignment.pdf
os lab assignment.pdf
 
Pl python python w postgre-sql
Pl python   python w postgre-sqlPl python   python w postgre-sql
Pl python python w postgre-sql
 
agri inventory - nouka data collector / yaoya data convertor
agri inventory - nouka data collector / yaoya data convertoragri inventory - nouka data collector / yaoya data convertor
agri inventory - nouka data collector / yaoya data convertor
 
pts_ldap
pts_ldappts_ldap
pts_ldap
 
Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本Shell实现的windows回收站功能的脚本
Shell实现的windows回收站功能的脚本
 
Paexec -- distributed tasks over network or cpus
Paexec -- distributed tasks over network or cpusPaexec -- distributed tasks over network or cpus
Paexec -- distributed tasks over network or cpus
 
Let's begin resource monitoring with munin 2011 1209 zem_distribution
Let's begin resource monitoring with munin 2011 1209 zem_distributionLet's begin resource monitoring with munin 2011 1209 zem_distribution
Let's begin resource monitoring with munin 2011 1209 zem_distribution
 

Recently uploaded

一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理
一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理
一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理
kywwoyk
 
1. WIX 2 PowerPoint for Work Experience.pptx
1. WIX 2 PowerPoint for Work Experience.pptx1. WIX 2 PowerPoint for Work Experience.pptx
1. WIX 2 PowerPoint for Work Experience.pptx
louise569794
 
NO1 Uk Amil Baba In Lahore Kala Jadu In Lahore Best Amil In Lahore Amil In La...
NO1 Uk Amil Baba In Lahore Kala Jadu In Lahore Best Amil In Lahore Amil In La...NO1 Uk Amil Baba In Lahore Kala Jadu In Lahore Best Amil In Lahore Amil In La...
NO1 Uk Amil Baba In Lahore Kala Jadu In Lahore Best Amil In Lahore Amil In La...
Amil baba
 
一比一原版UVM毕业证佛蒙特大学毕业证成绩单如何办理
一比一原版UVM毕业证佛蒙特大学毕业证成绩单如何办理一比一原版UVM毕业证佛蒙特大学毕业证成绩单如何办理
一比一原版UVM毕业证佛蒙特大学毕业证成绩单如何办理
kywwoyk
 
一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理
一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理
一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理
eemet
 

Recently uploaded (8)

F5 LTM TROUBLESHOOTING Guide latest.pptx
F5 LTM TROUBLESHOOTING Guide latest.pptxF5 LTM TROUBLESHOOTING Guide latest.pptx
F5 LTM TROUBLESHOOTING Guide latest.pptx
 
Memory compiler tutorial – TSMC 40nm technology
Memory compiler tutorial – TSMC 40nm technologyMemory compiler tutorial – TSMC 40nm technology
Memory compiler tutorial – TSMC 40nm technology
 
一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理
一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理
一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理
 
1. WIX 2 PowerPoint for Work Experience.pptx
1. WIX 2 PowerPoint for Work Experience.pptx1. WIX 2 PowerPoint for Work Experience.pptx
1. WIX 2 PowerPoint for Work Experience.pptx
 
NO1 Uk Amil Baba In Lahore Kala Jadu In Lahore Best Amil In Lahore Amil In La...
NO1 Uk Amil Baba In Lahore Kala Jadu In Lahore Best Amil In Lahore Amil In La...NO1 Uk Amil Baba In Lahore Kala Jadu In Lahore Best Amil In Lahore Amil In La...
NO1 Uk Amil Baba In Lahore Kala Jadu In Lahore Best Amil In Lahore Amil In La...
 
NO1 Pandit Black magic/kala jadu,manpasand shadi in lahore,karachi rawalpindi...
NO1 Pandit Black magic/kala jadu,manpasand shadi in lahore,karachi rawalpindi...NO1 Pandit Black magic/kala jadu,manpasand shadi in lahore,karachi rawalpindi...
NO1 Pandit Black magic/kala jadu,manpasand shadi in lahore,karachi rawalpindi...
 
一比一原版UVM毕业证佛蒙特大学毕业证成绩单如何办理
一比一原版UVM毕业证佛蒙特大学毕业证成绩单如何办理一比一原版UVM毕业证佛蒙特大学毕业证成绩单如何办理
一比一原版UVM毕业证佛蒙特大学毕业证成绩单如何办理
 
一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理
一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理
一比一原版SDSU毕业证圣地亚哥州立大学毕业证成绩单如何办理
 

Pop3stat sh

  • 1. #!/bin/bash # Tue Feb 17 17:36:38 EST 2004 # NAME: pop3stat # Copyright 2004, Chris F.A. Johnson # Released under the terms of the GNU General Public License # check POP3 server for e-mail ## set these variables to appropriate values pop=pop.your-isp.com user=$USER pass=password image=$HOME/mail.png ## or put them into the config file configfile=$HOME/.pop3statrc pop3stat() { exec 3<>/dev/tcp/$pop/110 popcmd user $user || return 1 popcmd pass $pass || return 2 popcmd stat || return 3 popcmd quit || return 4 } popcmd() { local IFS=${IFS}$'r' cmd=$* echo $cmd >&3 read ok num x <&3 [ $verbose -ge 1 ] && printf "%sn" "$1: $ok $num $x" [ "$ok" = "+OK" ] } popupicon() { set -- $(ps awwwxo user,pid,command | grep "$USER.*[m]ail-notify.*$image") [ -n "$2" ] && kill $2 [ $num -gt 0 ] && { display -geometry +1+1 -name mail-notify -comment "$num" $image & } } [ -s "$configfile" ] && . "$configfile" verbose=0 while getopts vc: var do case $var in c) configfile=$OPTARG ;; v) verbose=$(( $verbose + 1 )) ;; esac done shift $(( $OPTIND - 1 )) pop3stat || { echo "popcmd "$cmd" failed"; exit 5; } case ${1:-t} in g) popupicon ;; t) [ $num -eq 1 ] && _PL= || _PL=s echo "You have $num message$_PL" ;; esac