Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use LWP::UserAgent;
- my $hostout = `curl http://ifconfig.me/ip`; #адрес нашего роутера
- if ($hostout =~ /(\d+)\.(\d+)\.(\d+)\.(\d+)/) {
- my $ip = "$1.$2.$3.$4";
- #Добавлено:
- open (FILE,"my_ip.txt");
- my @lines = <FILE>;
- $old_ip = $lines[0]; #Считываем IP из файла
- $old_ip =~ s/^\s+|\s+$//g; #trim
- close(FILE);
- if ($old_ip eq $ip) {
- die "IP not changed"; # Выходим из скрипта, если IP не изменился
- }
- open (FILE,">my_ip.txt");
- print FILE $ip; # Записываем в файл новый IP
- close(FILE);
- my $token = "f5716bb71da669f414b1b29e7f26027bcc51cb784780b5444066b8a3";
- my $domain00 = "fisab.ru";
- my $id00 = "32357995";
- my $subdomain01 = "www";
- my $id01 = "32357995";
- my $url00 ="https://pddimp.yandex.ru/nsapi/edit_a_record.xml?token=$token&domain=$domain00&record_id=$id00&content=$ip";
- my $url01 ="https://pddimp.yandex.ru/nsapi/edit_a_record.xml?token=$token&domain=$domain00&subdomain=$subdomain01&record_id=$id01&content=$ip";
- my $ua = LWP::UserAgent->new( ssl_opts => { verify_hostname => 0 } );
- my $response = $ua->get($url00);
- if ( $response->is_success ) {
- print $response->decoded_content;
- } else {
- die $response->status_line;
- }
- my $response = $ua->get($url01);
- if ( $response->is_success ) {
- print $response->decoded_content;
- } else {
- die $response->status_line;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement