Register
It is currently Tue Sep 30, 2014 5:50 am

Bash script to incorrectly log into email without GUI... =D


All times are UTC - 6 hours


Post new topic Reply to topic  [ 5 posts ] 
Author Message
 PostPosted: Wed Feb 04, 2009 10:20 am   

Joined: Wed Feb 04, 2009 10:12 am
Posts: 1
lol. I know it sounds really strange, but hear me out.

Basically, I have an old PC without monitor, keyboard, or mouse, that I run linux on. Connect via SSH. Now, I usually keep files on there and grab them from various locations (I have internet anywhere on my laptop). The problem lies in the fact that I have a dynamic IP (cant be helped). And whats worse? It resets quite often. So, I need a way to have an active monitor of what my IP is.

Of course, there are programs out there that I pay money and it will automatically update my IP randomly. But I'm a cheapo and want to do it the free way. =D Now, the best idea I could come up with (being a Linux newb and all) was that one my email addresses will log the IP of any failed attempt to log in. See where I'm going with this? If it is possible at all to create a script that would attempt to incorrectly log into the email say once every 6 hours that would keep me up to date on my IP. =D Sneaky, huh?

I don't know the first thing about bash, and learning it doing this is turning out to be a real joy. If one of you could help me in this endeavor I'd be very grateful... I don't even know where to start! The email url Im trying to use is fastmail.fm . and it'll be just a general username I'll make later (something like "whatsmyip" or something.


Top
 Profile  
 PostPosted: Thu Feb 05, 2009 2:37 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
isn't it easier to either setup a dyndns or just ifconfig and then just email it to you?

Code:
#!/bin/bash
netdev=eth0
sender="sender@host.com"
reciever="reciever@host.com"
tmp_file="/tmp/ifconfig.$$"
ifconfig $netdev &> $tmp_file
sendmail -s "Ifconfig" -f $sender $reciever < $tmp_file
rm $tmp_file


You should probably make some kind of control if the ip has changed since the last mail.
Otherwise this would spam you everytime it runs.
(ps. Crontab is a good tool :D ds.)

Best regards
Fredrik Eriksson


Top
 Profile  
 PostPosted: Thu Feb 05, 2009 10:07 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
by no means putting you off having a bash method, however I use dynamic dns;
http://www.dyndns.com/services/dns/dyndns/

it's free and stable and there are plenty of docs online for automating updates to dynDNS


Top
 Profile  
 PostPosted: Fri Feb 06, 2009 5:51 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 667
Location: Des Moines, Iowa
DarthWavy wrote:
by no means putting you off having a bash method, however I use dynamic dns;
http://www.dyndns.com/services/dns/dyndns/

it's free and stable and there are plenty of docs online for automating updates to dynDNS


Agreed, and I wrote one for zoneedit.com. Setting a script that updates your dns info with your current ip and checks it every 5 minutes or so, and auto-updates the stuff for you is the way to go. Look into DarthWavy's link.


Top
 Profile WWW  
 PostPosted: Fri Feb 06, 2009 6:19 am   

Joined: Mon Nov 17, 2008 7:25 am
Posts: 221
dyndns supplies you with a daemonizable software named inadyn which can be set to update every 300 seconds.

Best regards
Fredrik Eriksson


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP