| Category: | E-Mail Programs |
| Author/Contact Info | w3b@da-mail.net |
| Description: | You can send command via e-mail from mobile phone and script will do it =] You have to write in subject or status: =command= and send:)You have to have module Net::POP3 |
CBE.pm
package CBE;
use warnings;
use strict;
my $pop3 = 'pop3.server';
my $login = 'email@adress';
my $pass = 'password';
my $number = 'phone_number';
sub check {
my $last;
if( -e 'num' ){
open(NUM, "num");
$last = int(<NUM>);
} else {
open(NUM, ">>num");
$last = '0';
}
close NUM;
my $pop = Net::POP3->new($pop3) || die("Can't connect");
my $now = $pop->login($login, $pass) || die("Can't connect");
if ($last < $now){
my $msg = $pop->get($now);
my $auth;
for my $line (@$msg){
if( $line =~ /(<$number@(.*)>)$/ ){
$auth = '1';
}
}
while( my $line = shift @$msg ) {
last while $line =~ /^Status:/;
}
chomp(@$msg);
my $string = @$msg[1];
if(@$msg[1] =~ /=(.*)=/){
my @arr=split(/=(.*)=/,$1);
if (system(`$arr[0]`)){
&log_save($arr[0],'yes');
} else {
&log_save($arr[0],'no');
}
}
}
open(WRI, ">num");
print WRI $now;
close WRI;
$pop->quit;
sleep 5;
}
sub log_save {
my $log = shift;
my $status = shift;
open(LOG, '>>log.txt');
print LOG "Command: $log\n";
print LOG "Date: ".localtime()."\n";
print LOG "Success: $status\n";
print LOG "-----------\n";
close LOG;
}
cbe.pl
#!/usr/bin/perl
use warnings;
use strict;
use Net::POP3;
use CBE;
while(1){
CBE::check();
}
|
|
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CBE - Controle by E-mail vr 1.1
by tirwhan (Abbot) on Mar 20, 2006 at 06:56 UTC | |
by w3b (Beadle) on Mar 20, 2006 at 12:58 UTC | |
by tirwhan (Abbot) on Mar 20, 2006 at 13:13 UTC | |
by w3b (Beadle) on Mar 20, 2006 at 14:02 UTC | |
|
Re: CBE - Controle by E-mail vr 1.1
by salva (Canon) on Mar 20, 2006 at 13:39 UTC | |
by w3b (Beadle) on Mar 20, 2006 at 14:07 UTC |