-
Want something in PERL
OK, here is what I'm trying to do:
I want to make PERL call up Fetchmail, which is easy enough with system, but can I make it type in a password for me as well? The only book I have as of yet is "Learning PERL" and I'm searching right now for a way to do this, I got passed the first chapter and then on to chapter like, 15 or so, I skipped ahead because the begining stuff bored me and I was able to figure a lot of it out on my own anyway but can this be done? I'd just like to be able to execute a PERL script to check my mail and then of course I can do **** from there.
-
Hi gore,
Does this help?...
http://www.linux-sec.net/Mail/etc.ma...dmail_etc.html
Linux security: mail, sendmail, fetchmail, procmail...
http://www.catb.org/~esr/fetchmail/fetchmail-FAQ.html
The Fetchmail FAQ
Eg ;)
-
Sort of, but the way that would be helpful is if I could maybe tell the script to wait a few seconds as fetchmail loads, and then print my pass and seem to hit enter.
Very new to coding and want to see what I can really make it do. The only limitations are those I set on me.
-
Hi gore,
Then how about these?...
http://lists.ccil.org/pipermail/fetc...er/006853.html
[fetchmail] perl alternative for --configdump
http://lists.ccil.org/pipermail/fetc...ly/008935.html
[fetchmail]Re: mail to a perl script
best I can come up with.
Eg ;)
-
I'm not sure if this will work but you could try something like:
Code:
open( FM, "| fetchmail") ;
print FM "mypassword";
close(FM);
Another option would be to use the Expect::Simple module.
-
Hi
As so often, there is not much left to say after SirDice :D
Nevertheless, I would go with expect. It is rather useful
to script, and, as mentioned, there is also a Perl module.
The two versions look as follows:
The "shell" version:
Code:
#!/usr/bin/expect
#more info: man expect
spawn fetchmail -u username mail.server.com
expect "mail.server.com:"
send "password\r"
expect eof
or with the Perl-module:
Code:
#!/usr/bin/perl
use Expect;
#more info: man Expect
$handle=Expect->spawn("fetchmail -u username mail.server.com")
or die "error while spawning\n";
$handle->expect(5,"mail.server.com:"); #wait 5 secs at max
$handle->send("password\n");
$handle->soft_close();
$handle->hard_close();
In both versions, you could pass the password as a command
line argument.
Cheers.
-
-
First, as for reading learning perl. Read the entire book from cover to cover, and then when you are done read it again. Once you are done with that. Pick up the Perl Cookbook, read that about 5 times. Then look for Programming in Perl. Once you are done with all of those, you question will seem to disappear.
Next, Learning perl won't explain to you how to do what you want to do. It is kind of out of the grasp of the book. Great book though, one of my favorites.
Next, I might be wrong when I say this, but SirDice, I am almost positive that you can't print a password to have it work. Kind of like trying to write a script to log-in with su. It won't work, now if the module you said works, I don't know. I am really crappy at using modules, I usually try to write everything myself.
Gore there is also a sleep function in perl.
sleep 60; I believe would work. It is based on seconds.
-
geez TT. The closest I've ever gotten to reading a programming book cover to cover was
reading about 100 pages out of a 600 page book. Other than that I've never really read
any programming books. In my opinion you have to be applying what you read as you
are learning it. You can't read a book cover to cover and just go do everything it taught you.
If you can I admire you. I know you said to read them a few times, but who in their right mind
would do that? Maybe that's why my coding style sucks so bad :). Oh well. I consider myself
a decent programmer and I owe most of it to classes. If you can read a book and learn that way
more power to you. Peace.
-
Thanks, WK2300, I tried to greeny you but I gave out to many today, probably for the help I got in this thread, I was looking for something along the lines of the sleep thing you said to do and as you rightly pointed out it was no where in that book. I've been going to online docs as well to pick up new things.
LOL, writing from reading is possible, Richard Stallman, before he owned a computer, wrote programs on paper and a few months after he got a computer he designed his own.
-
ZC, I agree with you on learning to do coding from practice, but a lot of things that you learn in coding you won't find out without reading a book, or documentation. You have to know how your compiler works on different things, and how to change settings on it, all of which you have to get from documentation or from a book. I am actually one more partial to messing up a lot and then going to look for the answer in a book or else where. But, sometimes just reading a book for the info in it will teach you sooo much.
Oh and Skiddie as for the book "Learning Perl" I think it is only 200 pages at the most. It is a really small book but covers everything that learning perl requires.
Perl is a very cool and fun language. I love the language, I wish I had more time to play with it. It is to me the fun language. I can do all kinds of things a lot simplier in it. I can also make my code so unimaginably un-readable in it, with such ease. I love the language. I could go on for hours about why I like it, but point being I wouldn't of learned most of the things I know about it without reading a little.
ZC, I am with you though, I have a lot of books that I am suppose to read, but never get around to because of laziness, or something else. Usually laziness though.