473,396 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

READMODE or READKEY from a file

2
I have a simple perl script as follow:

Expand|Select|Wrap|Line Numbers
  1.   use Term::ReadKey;
  2.  
  3.   print "Enter name: ";
  4.   ReadMode 2; #Turn off keyboard echo
  5.   $name = <>;
  6.   ReadMode 0;
  7.   print "$name \n";
Instead of read the input from keyboard, I would like to get from a file(a file that.only have one line). I did run the following command in Shell:
1) perl test.pl < input.txt
2) cat input.txt | perl test.pl

Both returned the following error:
Expand|Select|Wrap|Line Numbers
  1. GetConsoleMode failed, LastError=|6| at i:/site/lib/Term/ReadKey.pm line 265.
Since the readmode get the input from stdin, and I did pipe the file into stdin, why error out? Anything i did wrong?Any work around?Pls advice.

Thanks
Nov 19 '08 #1
2 5281
ahgan
13
Try removing the redirective "<" when calling the command.

Expand|Select|Wrap|Line Numbers
  1. perl test.pl input.txt
Nov 19 '08 #2
sebtks
2
Try removing the redirective "<" when calling the command.

Expand|Select|Wrap|Line Numbers
  1. perl test.pl input.txt
It's working. Thanks.
Nov 20 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
1
by: balzano_1 | last post by:
Hi, im trying to upload a file from a client (windows) to an ftp server (linux), i deciede to use some of php`s functions to connect and authenticate etc.. i only wish to put a file on the server,...
15
by: Simon | last post by:
I would like to create a very basic file upload add image form to add to my web site and to keep them in a "tmp" directory within my web hosting file manager once uploaded. I understand the basic...
1
by: Muttly | last post by:
Hey all. I'm trying to upload multiple files. I'm using the chm file from php.net to help me figure it out. I also checked online and say theres a problem with the file. Anyway My html looks like...
0
by: Lokkju | last post by:
I am pretty much lost here - I am trying to create a managed c++ wrapper for this dll, so that I can use it from c#/vb.net, however, it does not conform to any standard style of coding I have seen....
0
by: Dustan | last post by:
I found this site that has code for readkey for Windows, Unix, and in an updated version, Mac: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/134892 . The Mac object returns a character...
0
by: Dustan | last post by:
I've posted this before, but not gotten an answer: I found this site that has code that does readkey for Windows, Unix, and in an updated version, Mac:...
0
by: thjwong | last post by:
I'm using WinXP with Microsoft Visual C++ .NET 69462-006-3405781-18776, Microsoft Development Environment 2003 Version 7.1.3088, Microsoft .NET Framework 1.1 Version 1.1.4322 SP1 Most developers...
3
by: eper | last post by:
help! i'm new to c++ and i'm looking for the equivalent of the Pascal readkey in c++. is there any?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.