http://qs321.pair.com?node_id=11112743

ptone has asked for the wisdom of the Perl Monks concerning the following question:

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