- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to print control character in a text file
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
Forums
Discussions
Discussions
Discussions
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
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
10-27-2003 10:29 AM
10-27-2003 10:29 AM
how to print control character in a text file
How can I write a control character through a c program .
thanks
Prasad
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2003 10:38 AM
10-27-2003 10:38 AM
Re: how to print control character in a text file
(void) fflush(stdout);
You just sent ESC,'[','B' to stdout.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2003 11:00 AM
10-27-2003 11:00 AM
Re: how to print control character in a text file
could you please let me know how can I send the control character for these function keys
F6
F7
F18
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2003 11:21 AM
10-27-2003 11:21 AM
Re: how to print control character in a text file
Do this:
TERM=vt100 (or whatever)
export TERM
infocmp
Look for the kf6, kf7, and kf18 sequences (if defined).
Here's a simple method using the shell to do F6 -- which you could leverage using the system() function from within C.
KF6=$(tput kf6); echo "${KF6}\c"
Now the real C method is to use the curses tigetstr() function. You have to load the terminfo and then you can do:
char *F6;
F6 = tigetstr("kf6");
You have now captured the F6 sequence in a string and a simple
printf (or curses tparm command) will send it.
Man tigetstr for details and study curses because curses is one thing every UNIX programmer should at least have a little knowledge of. I have fired guys for hard-coding sequences into what was supposed to be portable code --- after they assured me that they were using terminfo.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2003 12:22 PM
10-27-2003 12:22 PM
Re: how to print control character in a text file
When I did this
TERM=vt220
export TERM
infocmp
KF6=$(tput kf6);
echo "${KF6}\c"
the echo didnt produce anything .
Am I missing something?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2003 03:48 PM
10-27-2003 03:48 PM
Re: how to print control character in a text file
> echo "${KF6}\c"
>
> the echo didnt produce anything .
> Am I missing something?
Yeah... the data is likely to be going in the wrong direction.
Are you per chance trying to 'pretent' an operator hit the KF6 key?
KF6 is a keystroke going from terminal to system. You are sending it to the terminal and it has no defined reaction for it.
If you could program a terminal to return key-strokes then this would normally be seen as a security violation.
close?
Regards,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2003 05:52 PM
10-27-2003 05:52 PM
Re: how to print control character in a text file
echo $KF6 | cat -tv
To do it from a C program, take a look at the (n)curses library.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2003 02:00 AM
10-28-2003 02:00 AM
Re: how to print control character in a text file
If you simply echo the characters to a terminal then it's likely that the terminal will interpret most of the sequence as control characters. If you want to actually see the characters then do this:
tput kf6 | od -c
Note that the kfN sequences are used by a curses enabled application to recogize that a particular key has been pressed. It's very unusual to actually want to send those characters from an application.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 09:19 AM
10-29-2003 09:19 AM
Re: how to print control character in a text file
What I did to print F6 is
fprintf(f1," %c06\n",06);
to print F7
fprintf(f1," %c07\n",06);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 09:24 AM
10-29-2003 09:24 AM
Re: how to print control character in a text file
Try this key sequence in vi -
ctrl+V Esc
It used to work when i was working with teletypes and VT100 settings.
- ramd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2003 09:50 AM
10-29-2003 09:50 AM
Re: how to print control character in a text file
You should really do this:
(void) fprintf(f1,"%c[17~",(char) 0x1B); /* kf6 */
(void) fprintf(f1,"%c[18~",(char) 0x1B); /* kf7 */
(void) fflush(f1);
and you are still not doing right even then because you asre not querying the terminfo database.