in reply to Escape variables

Please post a simple snippet of your code, how you ask for the password, how you capture it and how you store it. Your O/S is also perhaps relevant.

Replies are listed 'Best First'.
Re^2: Escape variables
by cbtshare (Monk) on Jan 06, 2016 at 06:41 UTC
    Below is the portion of my code relevant to the issue I am having, its a script to login to another system via ssh
    my $username; my $password; print "Please enter username to connect to the system:" ; chomp($username=<>); print "Please enter password\n"; chomp($password=<>);
      I think you you are getting what you want, but your printout statement is misleading you?

      #!usr/bin/perl use strict; my $in = 'r;OFTaf#a2Mt9d\1'; #single quote is literal quote #this is what your input should get print $in, "\n"; #print $in "as is", not within quotes =prints r;OFTaf#a2Mt9d\1
      a script to login to another system via ssh

      Don't mess with passwords, use public key authentication. See PuTTY FAQ "Remember Password" and Using public keys for SSH authentication. (Note that using public key authentication is not PuTTY specific, it's a basic feature of SSH.)

      Alexander

      --
      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      I have some quibbles about how you accept input. In a standard command line I/F leading or trailing spaces should not matter. But this looks to me like it should "work". How are you printing $password?
      I don't know what the rest of your code does.
      Code like this should get the input token and strip out the leading and trailing white-space.
      #/usr/bin/perl use warnings; use strict; my $username; print "Please enter username to connect to the system:" ; $username=<>; $username =~ s/^\s+//; #trim leading whitespace $username =~ s/\s+$//; #trim trailing whitespace #this includes \r, \n, etc. print $username, "\n";