Thread Wie funktioniert Net::Fritz::ConfigFile? (7 answers)
Opened by bianca at 2021-01-19 11:49

bianca
 2021-01-20 10:30
#193102 #193102
User since
2009-09-13
6975 Artikel
BenutzerIn

user image
Wen es interessiert: hiermit lädt man die Konfiguration eines FRITZ!-Geräts mittels TR064/TR-064 wie man sie auch über das Menü System --> Sicherung bekommt:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl
use strict;
use warnings;
use 5.010;

require Net::Fritz::Box;
require LWP::UserAgent;

##########################################
my $host = 'https://192.168.0.1:49443';
my $username = "user";           # Username for scripting at FritzBox
my $password = "pw1";      # Username's password at FritzBox
my $passwcfg = 'pw2';
##########################################

my $fb = Net::Fritz::Box->new(
    username => $username,
    password => $password,
    upnp_url => $host,
);
if (my $error = $fb->error) { die $error; }

my $device = $fb->discover;
if(my $error = $device->error) { die $error; }

my $Service = $device->find_service('DeviceConfig:1');
if(my $error = $device->error) { die $error; }

my $Response = $Service->call(
    'X_AVM-DE_GetConfigFile',
    'NewX_AVM-DE_Password' => $passwcfg
);
my $ConfigFileUrl = $Response->data->{'NewX_AVM-DE_ConfigFileUrl'}; # liefert z. B. https://192.168.0.1:38317/TR064/3CDEFF68

my $UserAgent = LWP::UserAgent->new();
$UserAgent->ssl_opts(
    verify_hostname => 0,
    SSL_verify_mode => 0
);
my $URI = URI->new($ConfigFileUrl);
my $Host = $URI->host();
my $Port = $URI->port();
$UserAgent->credentials("$Host:$Port",'HTTP Access',$username,$password);
$UserAgent->credentials("$Host:$Port",'HTTPS Access',$username,$password);
$Response = $UserAgent->get($ConfigFileUrl);
    
unless($Response->is_success) {
    my $status_line = $Response->status_line;
    die "cannot download from URL '$ConfigFileUrl' -- $status_line";
}
say $Response->decoded_content;

Last edited: 2021-01-20 10:41:04 +0100 (CET)
10 print "Hallo"
20 goto 10

View full thread Wie funktioniert Net::Fritz::ConfigFile?