7 fprint(2, "usage: %s [-q] [-t seconds] command\n", argv0);
28 writewithoutcr(int fd, char *p, int i)
33 for(e = p+i; p < e; ){
34 q = memchr(p, '\r', e-p);
38 if(write(fd, p, q-p) < 0)
43 if(write(fd, p, e-p) < 0)
49 readln(int fd, char *buf, int n)
56 i = read(fd, buf+sofar, 1);
71 docmd(char *cmd, int timeout, int quiet, int consfd)
78 if(*cmd == 'd' || *cmd == 'D')
84 p = smprint("at%s\r", cmd);
85 for(cp = p; *cp; cp++){
93 i = readln(0, buf, sizeof(buf));
95 rerrstr(buf, sizeof buf);
99 writewithoutcr(consfd, buf, i);
100 for(i = 0; i < nelem(tab); i++)
101 if(cistrstr(buf, tab[i].resp)){
113 main(int argc, char **argv)
124 timeout = atoi(EARGF(usage()));
136 consfd = open("/dev/cons", ORDWR);
138 sysfatal("opening /dev/cons: %r");
140 for(i = 0; i < argc; i++)
141 docmd(argv[i], timeout, quiet, consfd);