Send input str direct to tty

Submitted by lepton on Fri, 07/10/2020 - 13:16

//simulate terminal input

#include <sys/ioctl.h>
#include <termios.h>
#include <stdio.h>
#include <stdlib.h>

 

void stackchar(char c) {
    if (ioctl(0, TIOCSTI, &c) < 0) {
        perror("ioctl");
        exit(1);
    }
}
int main(int argc, char *argv[]) {
    char *str=argv[1];
    int len=(int)strlen(str);
    for (int i=0; i<len; i++) {
        stackchar(str[i]);
    }
    stackchar('\n');
    return 0;;
}

Comments

kobe basketbal… (not verified)

Wed, 04/21/2021 - 12:37

I in addition to my pals were checking out the nice information found on your web page and then before long developed a terrible suspicion I never thanked the blog owner for those secrets. Most of the women happened to be happy to learn them and have in actuality been using those things. I appreciate you for simply being well helpful and then for obtaining this kind of fine useful guides millions of individuals are really eager to know about. My honest apologies for not saying thanks to you sooner.
kobe basketball shoes http://www.kobebasketballshoes.net

spongebob kyrie 5 (not verified)

Wed, 04/21/2021 - 12:38

My husband and i have been now thrilled that Louis could complete his investigation out of the ideas he grabbed from your very own blog. It is now and again perplexing to simply choose to be making a gift of hints that many other folks could have been selling. Therefore we recognize we've got the writer to give thanks to for that. The type of explanations you have made, the simple web site menu, the relationships you will help create - it's mostly remarkable, and it is letting our son in addition to us believe that the theme is awesome, and that is extremely important. Thanks for everything!
spongebob kyrie 5 http://www.kyrie5spongebob.us

golden goose (not verified)

Wed, 04/21/2021 - 12:38

Thank you for all of your effort on this web site. My mom delights in setting aside time for investigation and it is easy to understand why. We learn all about the compelling mode you produce valuable tips and tricks via your web site and as well as improve participation from others on that concept so our own simple princess is without a doubt learning a lot. Have fun with the rest of the new year. You're the one performing a stunning job.
golden goose http://www.goldengooseoutletstore.com

jordan shoes (not verified)

Wed, 04/21/2021 - 12:38

I precisely had to appreciate you once more. I'm not certain the things I could possibly have achieved without those tips and hints documented by you relating to such a topic. It had been a real frightful setting in my circumstances, nevertheless observing the very skilled technique you resolved the issue made me to leap for gladness. Now i am happy for this assistance as well as believe you are aware of a great job you have been accomplishing training men and women with the aid of a web site. More than likely you've never encountered all of us.
jordan shoes http://www.michaeljordanshoes.us.com

Add new comment

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.