diff --git a/apps/cli/cli_pipe.c b/apps/cli/cli_pipe.c index 845ee7a8..a1e30009 100644 --- a/apps/cli/cli_pipe.c +++ b/apps/cli/cli_pipe.c @@ -31,6 +31,7 @@ ***** END LICENSE BLOCK ***** * + * Note, here assume all binaries are in /bin */ #ifdef HAVE_CONFIG_H @@ -68,43 +69,142 @@ #include "clixon_cli_api.h" /* Grep pipe output function + * + * @param[in] h Clixon handle + * @param[in] cmd Command to exec + * @param[in] option Option to command (or NULL) + * @param[in] value Command argument value (or NULL) + * @code + * grep , grep_fn("-e", "arg"); + * @endcode */ int -grep_fn(cligen_handle h, - cvec *cvv, - cvec *argv) +pipe_arg_fn(clicon_handle h, + const char *cmd, + const char *option, + const char *value) { int retval = -1; - cbuf *cb = NULL; - cg_var *av; - cg_var *cv; - char *name; - if ((cb = cbuf_new()) == NULL){ - perror("cbuf_new"); + /* XXX rewrite using execv */ + if (option){ + if (value){ + fprintf(stderr, "%s (1): %s %s %s %s NULL\n", __FUNCTION__, cmd, cmd, option, value); + retval = execl(cmd, cmd, option, value, NULL); + } + else{ + fprintf(stderr, "%s (2): %s %s %s NULL\n", __FUNCTION__, cmd, cmd, option); + retval = execl(cmd, cmd, option, NULL); + } + } + else{ + if (value){ + fprintf(stderr, "%s (3): %s %s %s NULL\n", __FUNCTION__, cmd, cmd, value); + retval = execl(cmd, cmd, value, NULL); + } + else{ + fprintf(stderr, "%s (4): %s %s NULL\n", __FUNCTION__, cmd, cmd); + retval = execl(cmd, cmd, NULL); + } + } + return retval; +} + +/* Grep pipe output function + * + * @param[in] h Clicon handle + * @param[in] cvv Vector of cli string and instantiated variables + * @param[in] argv String vector of options. Format: