- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: getch not working on HP-UX
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2010 03:56 AM
тАО09-14-2010 03:56 AM
getch not working on HP-UX
I need to use getch in my application for masking the password. I am using getch from curses.h.
Below is the my code:
#include
#include
using namespace std;
int main()
{
cout<<"\nBefore getch";
getch();
cout<<"\nafter getch";
return 0;
}
I am compiling using aCC:
aCC -O -mt -AA +Z +eh +DAportable -w -Wc,-ansi_for_scope,off -DUNICODE -D_UNICODE -D_INCLUDE_STDC_A1_SOURCE -D_INCLUDE__STDC_A1_SOURCE -D_UNIX_ -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS test.cpp -lcurses
It is compiling successfully but when i am running a.out then it is not waiting for the input and just printing the two statements and program ends.
bash-2.04$ a.out
Before getch
after getchbash-2.04$
Please guide me how to make getch() working on HP.
Thanks in advance for your help
- Tags:
- curses
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2010 05:03 AM
тАО09-14-2010 05:03 AM
Re: getch not working on HP-UX
From the 'getch(3X)' manpages:
int getch(void);
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2010 05:07 AM
тАО09-14-2010 05:07 AM
Re: getch not working on HP-UX
nt main()
{
cout<<"\nBefore getch";
int val = getch();
cout<<"\nafter getch";
return 0;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2010 05:34 AM
тАО09-14-2010 05:34 AM
Re: getch not working on HP-UX
I meant to suggest that if you capture the character returned by 'getch()' then you need to output whatever you captured.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2010 03:17 PM
тАО09-14-2010 03:17 PM
Re: getch not working on HP-UX
I get -1, possibly because?
If in nodelay mode and no data is available, ERR is returned.
#include
#include
int main() {
printf("Before getch:");
int char_in = getch();
printf("\nGot: %.2x|%c\n", (unsigned char)char_in, char_in);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-14-2010 11:29 PM
тАО09-14-2010 11:29 PM
Re: getch not working on HP-UX
Thanks a lot for your timely help!
I am getting below output after running your code snippet that displays the output of getch
bash-2.04$ a.out
Before getch:
Got: ff|├Г┬┐
bash-2.04$
Please suggest me some way on how to fix this. Do i need to set some delay?
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2010 02:34 AM
тАО09-15-2010 02:34 AM
Re: getch not working on HP-UX
You are actually going to have to read the curses documentation. A good starting point would be curses_intro(3X).
I assume you need to tell curses what window or terminal to read from, possibly these:
initscr() or newterm() to initialise Curses and restores these settings when endwin()
>I need to use getch in my application for masking the password.
Perhaps you should toss getch and just turn on and off echoing?