X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=miniexpect.pod;h=74538599342012b577d6370bfbb165d4566e9482;hb=HEAD;hp=d6404849b9c79e5ce5c331c577ffe302b31604d0;hpb=9a43a3bea411be5de83c64a2f1d28f365de7133f;p=miniexpect.git diff --git a/miniexpect.pod b/miniexpect.pod index d640484..7453859 100644 --- a/miniexpect.pod +++ b/miniexpect.pod @@ -2,7 +2,7 @@ =head1 NAME -miniexpect - A very simple expect library for C. +miniexpect - A very simple expect library =head1 SYNOPSIS @@ -302,7 +302,7 @@ returned in C. =item C -There was a C error. Cpcre_error> is set to the +There was a C error. Cpcre_error> is set to the error code. See L for a list of the C error codes and what they mean. @@ -367,13 +367,15 @@ literal" and is available in C99. If you need to use an older compiler, you can just use a local variable instead. mexp_h *h; - char *errptr; + int errcode; int offset; pcre2_code *password_re, *prompt_re; pcre2_match_data *match_data = pcre2_match_data_create (4, NULL); - password_re = pcre_compile ("assword", 0, &errptr, &offset, NULL); - prompt_re = pcre_compile ("[$#] ", 0, &errptr, &offset, NULL); + password_re = pcre2_compile ("assword", PCRE2_ZERO_TERMINATED, + 0, &errcode, &offset, NULL); + prompt_re = pcre2_compile ("[$#] ", PCRE2_ZERO_TERMINATED, + 0, &errcode, &offset, NULL); switch (mexp_expect (h, (mexp_regexp[]) { @@ -382,10 +384,12 @@ compiler, you can just use a local variable instead. { 0 }, }, match_data)) { case 100: - /* here you would send a password */ + /* server printed a password prompt, so send a password */ + mexp_printf_password (h, "%s", password); break; case 101: - /* here you would send a command */ + /* server sent a shell prompt, send a command */ + mexp_printf (h, "ls\n"); break; case MEXP_EOF: fprintf (stderr, "error: ssh closed the connection unexpectedly\n");