Forum Discussion
using perl iControl for system backups / archives
Hello @nesh
I want to handle error HTTP401 when authenticatin failure occured. But I can't. Please show me how to work expectedly. I wrote below code,but still exits prematurely.So perl script ends with return code 0 regardless of authentication error.
use SOAP::Lite + trace => qw(method debug);
use SOAP::Lite;
use MIME::Base64;
use Data::Dumper;
my $sHost = $ARGV[0];
my $sUID = $ARGV[1];
my $sPWD = $ARGV[2];
my $sProtocol = "https";
my $sPort = 443;
$SaveConfig = SOAP::Lite
-> uri('urn:iControl:System/ConfigSync')
-> proxy("$sProtocol://$sHost:$sPort/iControl/iControlPortal.cgi");
$SaveConfig->transport->http_request->header(
'Authorization' =>
'Basic' . MIME::Base64::encode("$sUID:$sPWD",'')
);
eval {$soap_response = $SaveConfig->get_configuration_list();};
if ($@) {
print "ERROR: $@\n";
die "authentication error!!";
}Best regards.
- Oct 24, 2017
You need a space after "Basic" in the authentication header.
$SaveConfig->transport->http_request->header( 'Authorization' => 'Basic ' . MIME::Base64::encode("$sUID:$sPWD",'') );The correct format of the header should be
Authorization: Basic FADSFZDSAFDSAFDSAFDASF
Without the space it's coming through as
Authorization: BasicFDSFDSDFASAFDSAF
Not sure if this answers the catching of the exception question, but it should allow you to authenticate with correct credentials.
-Joe
- wani_67522Oct 25, 2017
Nimbostratus
thanks Joe.
I did a type mistake when writing in this web form. I actually run script with space like 'Basic ' and can't catch the exception of invalid authentication bye eval command.
I can get valid authentication with correct user and password.
I wonder whether there are problem on environment with running SOAP script.
environment with running SOAP Script is below
AIX 5.3.0 and Perl 5.8.8
regards.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com