Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Reading input from the STDIN through console

2008-07-25
2013-05-20
  • I am using Eclispe 3.4 - EPIC 0.6.24 on WinXP machine.
    I was able to run the perl script from Eclipse
    and was able to user entered the data when it prompts to read input from (Eclipse console) on using $pwd=<STDIN>;
    But, following is not working since, trying to use the stty -noecho concept for password reading.
    use Term::ReadKey;
        ReadMode 'noecho';
        my $password = ReadLine 0;
        chomp ($password);    # Removes all CR and LF from the end of the line.
        ReadMode 'normal';
        return $password;

     
    • Whereas, if I run from command prompt, it will work.
      But, its working not in Eclipse console and giving following error.

      Enter your cws password: GetConsoleMode failed, LastError=|6| at C:/Perl/lib/Term/ReadKey.pm line 264.
      [code]
      #!c:/perl/bin/perl -w
      $|=1; # make STDOUT unbuffered
      use Term::ReadKey;
      print "Enter your cws password: ";
      my $pwd = &_password();

      sub _password() {
      ReadMode 'noecho'; 
      my $password = ReadLine 0; 
      chomp ($password); # Removes all CR and LF from the end of the line. 
      ReadMode 'normal'; 
      return $password;
      }

      [/code]

      Though, I am not sure to post this issue in the Eclispe forum or EPIC forum?

      Thanks for any help.

      ~ Subba

       
      • Jan Ploski
        Jan Ploski
        2008-07-25

        When you run a script in Eclipse, it is a forked process and the communication between the Eclipse console and the Perl process occurs durign stdout/stderr/stdin streams. There is no terminal to be controlled.