Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9253631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:16:03+00:00 2026-06-18T11:16:03+00:00

#!/usr/bin/perl use strict; use warnings; my $username = ‘$ARGV[0]’; my $password = ‘$ARGV[1]’; use

  • 0
#!/usr/bin/perl

use strict;
use warnings;
my $username = '$ARGV[0]';
my $password = '$ARGV[1]';
use Net::SSH::Expect;
my $ssh = Net::SSH::Expect-> new (
        host => "10.38.228.230",
        password => "lsxid4",
        user => "root",
        raw_pty => 1,
        timeout => 10,
        log_file => "log_file"  
);

my $login_output=$ssh->login();
if ( $login_output =~ /Last/ )
   {
   print "The login for ROOT was successful, Let's see if we can change the password \n";
   $ssh->send("passwd $username");
   $ssh->waitfor ('password:\s*', 10) or die "Where is the first password prompt??";
   $ssh->send("$password");
   $ssh->waitfor ('password:\s*', 10) or die "Where is the Second password promp??";
   $ssh->send("$password");
   $ssh->waitfor('passwd:\s*',5);
   print "The password for $username has been changed successfully \n";
   }
   else
   {
      die "The log in for ROOT was _not_ successful.\n";
   }

I am trying to chenge the users password on a remote host by logging to the host as root
but $username, $password doesn’t seem to take the values instead if i give hard coded values inside the code it works.

running like this on command line :

bash-3.00# ./test6.pl rak xyz12   
The login for ROOT was successful, Let's see if we can change the password
Where is the first password prompt?? at ./test6.pl line 22.
bash-3.00#

how can i change the users password remotely

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T11:16:05+00:00Added an answer on June 18, 2026 at 11:16 am

    The problem is that you are using single quotes here:

    my $username = '$ARGV[0]';
    my $password = '$ARGV[1]';
    

    First off, it is quite unnecessary to quote a variable this way. Second, when using single quotes, the content is not interpolated, it is just the literal string $ARGV[0].

    This should be:

    my $username = $ARGV[0];
    my $password = $ARGV[1];
    

    But a more elegant solution is:

    my ($username, $password) = @ARGV;
    

    Take advantage of the possibility to make the assignment in list context. Or:

    my $username = shift;
    my $password = shift;
    

    shift will implicitly shift arguments off either @ARGV or @_, depending on context (whether you are inside a subroutine or not).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#!/usr/bin/env perl use warnings; use strict; use Excel::Writer::XLSX; my $workbook = Excel::Writer::XLSX->new( 'perl.xlsx' );
#!/usr/bin/env perl use warnings; use strict; use 5.012; use XML::LibXML::Reader; my $reader = XML::LibXML::Reader->new(
with #!/usr/bin/perl use warnings; use strict; use 5.010; use SQL::Parser; my $parser = SQL::Parser->new(
I have this code which works. #!/usr/bin/perl use warnings; use strict; use Net::LDAP; use
Consider: #!/usr/bin/perl use strict; use warnings; my %hash; foreach (1 .. 10) { $hash{$_}
i have something like: #!/usr/bin/perl use strict; use warnings; use CGI::Simple; use DBI; my
When I do this #!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $s =
This code triggers the complaint below: #!/usr/bin/perl use strict; use warnings; my $s =
!/usr/bin/env perl use warnings; use strict; my $text = 'hello ' x 30; printf
Which version would you prefer? #!/usr/bin/env perl use warnings; use strict; use 5.010; my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.