Page 1 of 1
Easy BASH script question
Posted: Mon May 23, 2005 4:55 pm
by Chris Corbyn
Hi all,
Quite new to BASH scripting but I'm sure this is obvious to some.
Code: Select all
echo "e;... `fetchmail -c -u myusername localhost`"e;
That will run and ask me for my password. Well the thing is, I wanna put it in .profile so it runs when I log in, without being prompted for a password. Can I somehow (pipe or whatever) put the password in the BASH script itself?
Cheers

Posted: Tue May 24, 2005 5:02 am
by Chris Corbyn
Never mind I just wrote a PHP CLI script that does it better anyway with a splash of ANSI color.
Still curious if you can do what I wanted with BASH though

Posted: Tue May 24, 2005 5:14 am
by Weirdan
hmmm... perhaps something like this:
Code: Select all
echo `echo "e;pAssWord"e; | fetchmail -c -u user localhost`;
Posted: Tue May 24, 2005 12:26 pm
by Chris Corbyn
Yeah i tried that but it gives error "Fetchmail: password not supplied" or something to that effect - it wont prompt for P/W that way but on the same token it doesnt read one.
Well I've realised how cool you make some PHP apps for CLI as a result anyway, playing with the ANSI settings to beautify things a bit.
Thanks anyway

Posted: Tue May 24, 2005 3:55 pm
by pickle
MySQL allows you to pass the password command line-wise using the -p[password immediately after] flag
ie:
fetchmail might work the same
Posted: Wed May 25, 2005 3:20 am
by timvw
This is how my .fetchmailrc file looks like
Code: Select all
# scarlet accounts
poll pop.scarlet.be with proto pop3
user "e;euki"e; with password "e;xxxxxxx"e; is "e;timvw"e; here
user "e;vwadsl"e; with password "e;xxxxxx"e; is "e;timvw"e; here
user "e;aardbei"e; with password "e;xxxxxx"e; is "e;timvw"e; here
user "e;mv076639"e; with password "e;xxxxx"e; is "e;timvw"e; here
options fetchall
# khleuven accounts
poll mail.student.khleuven.be with proto imap
user "e;0040516"e; with password "e;xxxxxx"e; is "e;timvw"e; here
options fetchall ssl
This way, you only need to type "fetchmail" without entering a password.
Or you can run it in daemon mode: fetchmail -d 1800
(mail will be retrieved every 1800 seconds = 30 minutes)
So you can add something like "/usr/bin/fetchmail -d 1800" to your .profile or .bashrc or whatever
Currently i have the following in my cron file (to make sure the fetchmail daemon is started when the machine is booted...)
Code: Select all
@reboot /usr/bin/fetchmail -d 1800
Posted: Wed May 25, 2005 6:18 am
by Chris Corbyn
Cheers tim that's great.
I'll have another play
