Hi Team,
I am trying to use arguments to pass information from the command line into a perl script. These are the IP, Email, the User and the password. The IP works but the rest does not get parsed into the req for the content. If I hardcode these the script works.
##!/usr/bin/perl -l
use strict;
use warnings;
use LWP::UserAgent;
my $username = "Polycom";
my $password = "789";
my $phoneip = $ARGV[0];
my $user = $ARGV[1];
my $Address = $ARGV[2];
my $passcode = $ARGV[3];
my $ua = LWP::UserAgent->new(
ssl_opts => { verify_hostname => 0 },
protocols_allowed => ['https'],
);
my $URL = "https://$phoneip/api/v1/mgmt/skype/signIn";
{
# Create the request object and add the authentication header and cont
+ent
my $req = HTTP::Request->new(POST => $URL);
$req->content_type('application/json');
$req->authorization_basic( $username, $password );
$req->content('{"data":{"Address": "$Address","User": "$user","Passw
+ord": "$passcode","Domain":"","LockCode":""}}');
# Send the request to the user agent and print the result
my $response = $ua->request($req);
print "\r\n";
print $response->decoded_content;
}
With the above, I am trying to help one of our customers to remotely sign into a Phone but I cannot parse the info. It must be something little but I am stuck. Could someone kindly help me out? I actually managed the same in Power Shell but I like to offer various examples to them.
Best Regards
Steffen
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|