Find the answer to your Linux question:
Results 1 to 3 of 3
Assuming I have an executable: Code: for (;;){ x=getchar(); if(x=='q') { printf("exit"); exit(0); } else printf("Press a key"); } How to write a script to drive this executable simulating human ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined! legendbb's Avatar
    Join Date
    Mar 2007
    Location
    Canada
    Posts
    27

    Red face use bash to drive executable, and process stdout from the executable.


    Assuming I have an executable:
    Code:
    for (;;){
      x=getchar();
      if(x=='q') {
        printf("exit");
        exit(0);
      }
      else
        printf("Press a key");
    }
    How to write a script to drive this executable simulating human behavior?

    For example: send 'a', 'q' and process executable stdout message (printf);

    Great thanks,

    A short example script is very very much appreciated.
    Last edited by legendbb; 07-07-2011 at 01:30 PM.

  2. #2
    Just Joined! legendbb's Avatar
    Join Date
    Mar 2007
    Location
    Canada
    Posts
    27
    Or other tools to use in driving this executable.
    Please suggest.

  3. #3
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,391
    Maybe expect will help you
    Code:
    man expect
    You must always face the curtain with a bow.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •