LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-10-2017, 03:00 PM   #16
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019

It's possible to inject characters at the tty layer using an IOCTL, e.g. in C, something like:
Code:
#include <sys/ioctl.h>
#include <termios.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
  
  static struct termios tc_save, tc_new;
  char *p; 

  if (argc > 1 ) 
  {
    p=argv[1];

    tcgetattr(0, &tc_save);
  
    tc_new = tc_save;
    tc_new.c_lflag &= ~ECHO;
    tcsetattr(0, TCSANOW, &tc_new);

    while ( *p )
      ioctl(0,TIOCSTI, p++);

    tcsetattr(0, TCSANOW, &tc_save);
  }
  return 0; 
}
One could use such a helper in a script to achieve the desired result.

I'm not aware of an escape sequence to do this directly, but I have also seen the behaviour people describe when accidentally catting a binary file. What sequence triggers it and how specific to any particular terminal type it might be however I have no idea.

Last edited by GazL; 12-10-2017 at 03:05 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
learn shell scripting Tamilan Linux - Newbie 6 08-24-2012 02:55 AM
i want to learn shell scripting juglers Programming 12 04-12-2009 05:34 AM
Which scripting language to learn max_cherry Linux - Newbie 11 11-27-2008 12:47 PM
how to learn shell scripting G.Verma Linux - Laptop and Netbook 2 10-17-2007 06:55 AM
Want to learn Shell Scripting dawood Linux - General 3 08-04-2004 06:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration