Posted to tcl by rmax at Tue Apr 21 12:46:31 GMT 2015view raw

  1.  
  2. /* Compile with -lexpect -ltcl -ltclstub */
  3.  
  4. #include <stdio.h>
  5. #include <tcl.h>
  6. #include <expect.h>
  7. #include <expect_tcl.h>
  8.  
  9. int main (int c, char **a) {
  10. int fd;
  11. char *argv[] = { "ssh", "localhost", NULL };
  12.  
  13. Tcl_Interp *interp = Tcl_CreateInterp();
  14. if (Tcl_Init(interp) != TCL_OK) {
  15. fprintf(stderr, "Tcl_Init failed: %s\n", Tcl_GetStringResult(interp));
  16. return 1;
  17. }
  18. if (Expect_Init(interp) != TCL_OK) {
  19. fprintf(stderr, "Expect_Init failed: %s\n", Tcl_GetStringResult(interp));
  20. return 1;
  21. }
  22. fd = exp_spawnv ("ssh", argv); // <- this was segfaulting
  23. printf ("fd = %d\n", fd);
  24. return 0;
  25. }
  26.