Posted to tcl by rmax at Tue Apr 21 12:46:31 GMT 2015view raw
- /* Compile with -lexpect -ltcl -ltclstub */
- #include <stdio.h>
- #include <tcl.h>
- #include <expect.h>
- #include <expect_tcl.h>
- int main (int c, char **a) {
- int fd;
- char *argv[] = { "ssh", "localhost", NULL };
- Tcl_Interp *interp = Tcl_CreateInterp();
- if (Tcl_Init(interp) != TCL_OK) {
- fprintf(stderr, "Tcl_Init failed: %s\n", Tcl_GetStringResult(interp));
- return 1;
- }
- if (Expect_Init(interp) != TCL_OK) {
- fprintf(stderr, "Expect_Init failed: %s\n", Tcl_GetStringResult(interp));
- return 1;
- }
- fd = exp_spawnv ("ssh", argv); // <- this was segfaulting
- printf ("fd = %d\n", fd);
- return 0;
- }