June 15th, 2005, 04:46 AM
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.
June 15th, 2005, 05:11 AM
June 15th, 2005, 05:15 AM
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.
June 15th, 2005, 05:21 AM
Then how about these?...
[fetchmail] perl alternative for --configdump
[fetchmail]Re: mail to a perl script
best I can come up with.
June 15th, 2005, 09:32 AM
I'm not sure if this will work but you could try something like:
Another option would be to use the Expect::Simple module.
open( FM, "| fetchmail") ;
print FM "mypassword";
Experience is something you don't get until just after you need it.
June 16th, 2005, 06:28 PM
As so often, there is not much left to say after SirDice
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:
or with the Perl-module:
#more info: man expect
spawn fetchmail -u username mail.server.com
In both versions, you could pass the password as a command
#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
If the only tool you have is a hammer, you tend to see every problem as a nail.
(Abraham Maslow, Psychologist, 1908-70)
June 16th, 2005, 08:00 PM
June 16th, 2005, 10:16 PM
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.
June 17th, 2005, 12:37 AM
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.
June 17th, 2005, 02:01 AM
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.