1/* 2 * exp-test -- this is a simple C program to test the interactive functions of expect. 3 */ 4 5#include <stdio.h> 6#include <string.h> 7 8#define ARRAYSIZE 128 9 10main (argc, argv) 11int argc; 12char *argv[]; 13{ 14 char line[ARRAYSIZE]; 15 16 do { 17 memset (line, 0, ARRAYSIZE); 18 fgets (line, ARRAYSIZE, stdin); 19 *(line + strlen(line)-1) = '\0'; /* get rid of the newline */ 20 21 /* look for a few simple commands */ 22 if (strncmp (line,"prompt ", 6) == 0) { 23 printf ("%s (y or n) ?", line + 6); 24 if (getchar() == 'y') 25 puts ("YES"); 26 else 27 puts ("NO"); 28 } 29 if (strncmp (line, "print ", 6) == 0) { 30 puts (line + 6); 31 } 32 } while (strncmp (line, "quit", 4)); 33} 34