LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-15-2012, 01:15 PM   #1
acidrop
LQ Newbie
 
Registered: May 2005
Location: athens greece
Distribution: ubuntu,debian,centos
Posts: 23

Rep: Reputation: 0
shell script to delete alla messages from pop3 server?


Hello

I am looking for a shell script to totally remove (empty) all messages from
a specific account on a pop3 mail server.
Tried this one but it didn't work.

Any suggestions?
 
Old 05-15-2012, 02:11 PM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,661

Rep: Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133
if you know user/pass you can log in and delete all.
What is the problem with that solution?
 
Old 05-15-2012, 02:14 PM   #3
acidrop
LQ Newbie
 
Registered: May 2005
Location: athens greece
Distribution: ubuntu,debian,centos
Posts: 23

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
if you know user/pass you can log in and delete all.
What is the problem with that solution?
there are more than 56000 mails... can i delete them at once via telnet??
 
Old 05-15-2012, 02:24 PM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,661

Rep: Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133
as you see the script deletes messages one by one. If you have time it will do the job. In GUI probably you can mark 20 or 50 in one and delete them. Optionally you can delete user account and create it again. I do not see any way to execute a "delete-all" command. If there was a such command the mail server provider would help you.
 
Old 05-15-2012, 02:27 PM   #5
acidrop
LQ Newbie
 
Registered: May 2005
Location: athens greece
Distribution: ubuntu,debian,centos
Posts: 23

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
as you see the script deletes messages one by one. If you have time it will do the job. In GUI probably you can mark 20 or 50 in one and delete them. Optionally you can delete user account and create it again. I do not see any way to execute a "delete-all" command. If there was a such command the mail server provider would help you.
tried the script but i get:

+OK Send your password
+OK Mailbox locked and ready
./clean.pop3: 11: Syntax error: Bad for loop variable
Connection closed by foreign host.

I use the following syntax: ./clean.pop3 1000 | telnet pop3sever 110

Last edited by acidrop; 05-15-2012 at 02:28 PM.
 
Old 05-15-2012, 02:30 PM   #6
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,585

Rep: Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350
I think this is what "expect" is for but I've never used it myself so can't be any help other than to say google it, sorry.
Edit: Did you try hard coding the "1000" into the script rather than entering it on the command line?

Last edited by 273; 05-15-2012 at 02:32 PM.
 
Old 05-15-2012, 02:37 PM   #7
acidrop
LQ Newbie
 
Registered: May 2005
Location: athens greece
Distribution: ubuntu,debian,centos
Posts: 23

Original Poster
Rep: Reputation: 0
Did you try hard coding the "1000" into the script rather than entering it on the command line?

do you know how can i do that? i don't have scripting knowledge...
 
Old 05-15-2012, 02:38 PM   #8
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,661

Rep: Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133
Quote:
Originally Posted by acidrop View Post
tried the script but i get:

+OK Send your password
+OK Mailbox locked and ready
./clean.pop3: 11: Syntax error: Bad for loop variable
Connection closed by foreign host.

I use the following syntax: ./clean.pop3 1000 | telnet pop3sever 110
probably you need to try #!/bin/bash in the first line
 
Old 05-15-2012, 02:40 PM   #9
acidrop
LQ Newbie
 
Registered: May 2005
Location: athens greece
Distribution: ubuntu,debian,centos
Posts: 23

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by pan64 View Post
probably you need to try #!/bin/bash in the first line
thank you!!!! that worked... thank you very much
 
Old 05-15-2012, 02:46 PM   #10
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,585

Rep: Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350Reputation: 2350
Quote:
Originally Posted by pan64 View Post
probably you need to try #!/bin/bash in the first line
I feel stupid now, I didn't even look at the top of the script.
 
Old 05-16-2012, 12:23 AM   #11
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,661

Rep: Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133Reputation: 5133
Quote:
Originally Posted by 273 View Post
I feel stupid now, I didn't even look at the top of the script.
you have learned a lesson now.

Happy with solution ... mark as SOLVED

If someone helps you, or you approve of what's posted, click the "Add to Reputation" button, on the left of the post.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] shell script to delete a pattern from file deepmala8 Linux - Newbie 7 09-30-2011 12:28 AM
shell script to delete a file if it exists tkmsr Programming 11 08-10-2010 08:30 AM
delete messages in /var/mail/root using a script cccc Debian 1 09-11-2007 11:25 AM
delete mail via shell script kevin_obtiva Programming 1 12-10-2005 10:24 AM
pop3 inbox messages deleted from server malaka56 Linux - Software 2 08-11-2005 07:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 08:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration