azdps
July 17, 2016, 7:26pm
1
I'm currently using OpenBSD current as of yesterday. Both curl and wget aren't not part of the OpenBSD base and I would rather attempt to reboot my cable modem (SB6183) using perl HTTP:Tiny if possible. The following 2 commands work and both will reboot my modem:
curl -d Rebooting=1 http://192.168.100.1/goform/RgConfiguration
wget --post-data=Rebooting=1 http://192.168.100.1/goform/RgConfiguration
I would like to use the perl HTTP:Tiny module to reboot my router. Here is something I came up with that doesn't work. I need to implement post data Rebooting=1 for it to work but I can't figure that out:
perl -MHTTP::Tiny -E 'say HTTP::Tiny->new->post("http://192.168.100.1/goform/RgConfiguration")
Anyone have any ideas on proper HTTP::Tiny syntax so this will work?
Can't say I've played with HTTP::Tiny but have you tried:
perl -MHTTP::Tiny -E 'say HTTP::Tiny->new->post("http://192.168.100.1/goform/RgConfiguration?Rebooting=1")
azdps
July 17, 2016, 10:48pm
3
Chubler_XL unfortunately that did not work.
azdps
July 23, 2016, 5:35pm
4
All the following are working solutions to reboot the ARRIS SURFboard SB6183 cable modem:
Using curl
curl -d Rebooting=1 http://192.168.100.1/goform/RgConfiguration
Using wget
wget --quiet -O /dev/null --post-data=Rebooting=1 http://192.168.100.1/goform/RgConfiguration
Using HTTP:Tiny module included in Perl (one liner which can be used at a command prompt)
perl -MHTTP::Tiny -E 'HTTP::Tiny->new->post_form("http://192.168.100.1/goform/RgConfiguration", { Rebooting => 1 })'
Using a Perl script
#!/usr/bin/perl
use strict;
use warnings;
use HTTP::Tiny;
my $url = 'http://192.168.100.1/goform/RgConfiguration';
my $form_data = { Rebooting => 1 };
my $http = HTTP::Tiny->new;
my $response = $http->post_form($url, $form_data);
if ( $response->{success} ) {
print "Modem rebooted\n";
}
else {
print "Reboot failed: ", $response->{reason}, "\n";
}
Thanks to FishMonger for his help over at the http://perlguru.com forums.
.
.