summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b65cb1c)
raw | patch | inline | side by side (parent: b65cb1c)
author | Sebastian Harl <sh@teamix.net> | |
Mon, 10 Sep 2012 16:22:35 +0000 (18:22 +0200) | ||
committer | Sebastian Harl <sh@teamix.net> | |
Mon, 10 Sep 2012 16:24:23 +0000 (18:24 +0200) |
In order to follow the nomenclature used by Juniper.
doc/junosc.1.txt | patch | blob | history | |
src/junos.c | patch | blob | history | |
src/junos.h | patch | blob | history | |
src/junosc.c | patch | blob | history |
diff --git a/doc/junosc.1.txt b/doc/junosc.1.txt
index 65fba964db3654d418918315acbad2fbd18c1eb1..41c7b9ceacc41182566290e19c84999e1ca26530 100644 (file)
--- a/doc/junosc.1.txt
+++ b/doc/junosc.1.txt
SYNOPSIS
--------
-*junosc -H* '<hostname>' ['options'] '<command>'
+*junosc -H* '<hostname>' ['options'] '<method>'
DESCRIPTION
-----------
*junosc* is a client application to connect to routers running JUNOS software.
-It may be used to issue JUNOScript commands and display the response to the
+It may be used to issue JUNOScript method and display the response to the
user.
OPTIONS
diff --git a/src/junos.c b/src/junos.c
index 6a0fea6ef00223cb1705dd3aaca9b0afea7092f2..d254992cb6f1e886edeed264ba124eda5199bb3b 100644 (file)
--- a/src/junos.c
+++ b/src/junos.c
} /* junos_disconnect */
xmlDocPtr
-junos_simple_command(junos_t *junos, const char *cmd)
+junos_simple_method(junos_t *junos, const char *name)
{
- char cmd_string[1024];
+ char method_string[1024];
char recv_buf[4096];
ssize_t status;
xmlDocPtr doc;
- if ((! junos) || (! cmd)) {
+ if ((! junos) || (! name)) {
junos_set_error(junos, JUNOS_SYS_ERROR, EINVAL,
- "junos_simple_command() requires the "
- "'junos' and 'cmd' arguments");
+ "junos_simple_method() requires the "
+ "'junos' and 'name' arguments");
return NULL;
}
if (! junos->access) {
junos_set_error(junos, JUNOS_SYS_ERROR, EINVAL,
- "Please call junos_connect() before submitting commands");
+ "Please call junos_connect() before invoking a method");
return NULL;
}
- snprintf(cmd_string, sizeof(cmd_string),
- "<rpc><%s/></rpc>", cmd);
- status = junos_ssh_send(junos->access, cmd_string, strlen(cmd_string));
- if (status != (ssize_t)strlen(cmd_string)) {
- dprintf("Failed to send cmd '%s' (status %d)\n",
- cmd_string, (int)status);
+ snprintf(method_string, sizeof(method_string),
+ "<rpc><%s/></rpc>", name);
+ status = junos_ssh_send(junos->access,
+ method_string, strlen(method_string));
+ if (status != (ssize_t)strlen(method_string)) {
+ dprintf("Failed to send method '%s' (status %d)\n",
+ method_string, (int)status);
return NULL;
}
}
return doc;
-} /* junos_simple_command */
+} /* junos_simple_method */
/* error handling */
diff --git a/src/junos.h b/src/junos.h
index a88ad766902d76567541c620948b317651db34bb..5f31e917de5140306ad4fbaa92498b4736171318 100644 (file)
--- a/src/junos.h
+++ b/src/junos.h
junos_connect(junos_t *junos);
xmlDocPtr
-junos_simple_command(junos_t *junos, const char *cmd);
+junos_simple_method(junos_t *junos, const char *name);
int
junos_disconnect(junos_t *junos);
diff --git a/src/junosc.c b/src/junosc.c
index e08cc7788fb631edbac7aae7ddf334d977697f06..4b1bb6bfe1b17657a7ef42bcb8ace87931a99f4e 100644 (file)
--- a/src/junosc.c
+++ b/src/junosc.c
exit_usage(char *name, int status)
{
printf(
-"Usage: %s -H <host> [<options>] <command>\n"
+"Usage: %s -H <host> [<options>] <method>\n"
"\nOptions:\n"
" -H <host> hostname to connect to\n"
char *username = NULL;
char *password = NULL;
- char *command = NULL;
+ char *method = NULL;
junos_t *junos;
xmlDocPtr doc;
}
if (optind != argc - 1) {
- fprintf(stderr, "Missing command name\n");
+ fprintf(stderr, "Missing method name\n");
exit_usage(argv[0], 1);
}
- command = argv[optind];
+ method = argv[optind];
++optind;
if (use_netrc
}
junos_clear_error(junos);
- doc = junos_simple_command(junos, command);
+ doc = junos_simple_method(junos, method);
if (doc) {
xmlDocFormatDump(stderr, doc, /* format = */ 1);
xmlFreeDoc(doc);
}
else {
- fprintf(stderr, "Command failed: %s\n", junos_get_errstr(junos));
+ fprintf(stderr, "Method failed: %s\n", junos_get_errstr(junos));
}
junos_disconnect(junos);