LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   bash scripting auth check for pop3 (https://www.linuxquestions.org/questions/linux-general-1/bash-scripting-auth-check-for-pop3-798963/)

epsx 03-30-2010 03:09 PM

bash scripting auth check for pop3
 
I need to make a bash scripting, based on a password and a user, that connect to pop3 server and see if it login,if you can,return ok, otherwise return ERR .

if someone can help me i will appreciate it... thx.

rweaver 03-30-2010 03:26 PM

Generally we don't write scripts outright for people, but we'll be happy to help you with your script. I would suggest that perl (or language of your choice) or expect are better suited to this task than bash overall.

Also keep in mind pop3/imap are insecure protocols... you really should be using imaps or pop3s instead.

epsx 04-02-2010 07:02 AM

I know they are insecure, but i need only for checking pop3 connection (telnet localhost 110 , then echo username - echo pass), if will give me -ERR or +OK, and send me email if pop3 give -ERR or +OK... theat's all.
I am new in the world of linux, and i like it verry much to work on it :P. 3Mouth
The scrept i want to be in bash, it is simply.

THX.

(SRY FOR THE DELAY)

epsx 04-02-2010 09:07 AM

how far i worked at it :)...
(sleep 3;
echo user email account ex: linux@questions.org;
sleep 3;
echo pass email password;
sleep 3;
echo "quit") | telnet hostname 110

catkin 04-02-2010 09:47 AM

Quote:

Originally Posted by epsx (Post 3921680)
how far i worked at it :)...
(sleep 3;
echo user email account ex: linux@questions.org;
sleep 3;
echo pass email password;
sleep 3;
echo "quit") | telnet hostname 110

Does it work? If not, what are the symptoms?

epsx 04-02-2010 10:00 AM

It working but now i have to find a way how to send mail.
When he give -ERR (he can't connect) send me email, when can connect to give me email with +OK.

catkin 04-02-2010 10:14 AM

Quote:

Originally Posted by epsx (Post 3921760)
It working but now i have to find a way how to send mail.
When he give -ERR (he can't connect) send me email, when can connect to give me email with +OK.

If you can send mail from the command line then you can use something similar in the script.

Have a look at the command line mail clients "mail" and "mailx".

Presuming you want to send mail via a remote mail server you will also need a local mail server to send the locally-created mail to the remote server. This will probably be an SMTP mail server like sendmail or postfix -- or hopefully someone will suggest a simple one!

rweaver 04-02-2010 10:29 AM

Better than mail would be mutt or pine also... they're fairly full featured.

epsx 04-06-2010 05:53 AM

For now it done :), i add a cronjob. It ok for now, THX for the info and help :P.

(sleep 3;
echo user email account ex: linux@questions.org;
sleep 3;
echo pass email password;
sleep 3;
echo "STAT"
sleep 3;
echo "quit") | telnet hostname 110

catkin 04-06-2010 06:19 AM

Quote:

Originally Posted by epsx (Post 3925997)
For now it done :), i add a cronjob. It ok for now, THX for the info and help :P.

(sleep 3;
echo user email account ex: linux@questions.org;
sleep 3;
echo pass email password;
sleep 3;
echo "STAT"
sleep 3;
echo "quit") | telnet hostname 110

Does that do what you wanted -- "When he give -ERR (he can't connect) send me email,"? It looks like it sends some strings to port 110 on hostname; it doesn't look like it does anything if the telnet session doesn't connect.

epsx 04-06-2010 07:16 AM

yes, but i put in cronjob to give me at 10 hours email. I know it not a right way... he give all the information.
now i work on samba, i will focus later on it :P.
i will try with mailx, to send me email if he can "read -u 3;".


All times are GMT -5. The time now is 12:06 PM.