summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2004-01-16 15:02:30 +0000
committerVolker Lendecke <vlendec@samba.org>2004-01-16 15:02:30 +0000
commit91dd593ad14801bc5d5e31d3b14b4989264b95fc (patch)
tree408fb9987050d2395f6eefc8aabb338f62016656 /source3
parente51bba51a38f736b5eee011208a2664978dd8f70 (diff)
downloadsamba-91dd593ad14801bc5d5e31d3b14b4989264b95fc.tar.gz
samba-91dd593ad14801bc5d5e31d3b14b4989264b95fc.tar.bz2
samba-91dd593ad14801bc5d5e31d3b14b4989264b95fc.zip
Patch from "Stoian Ivanov" <sdr@bultra.com>: Add -g (greppable..) to
smbclient -L to make the output usable in pipes. Volker (This used to be commit 190beff495742d8e45f5e3621ece74c33570d31a)
Diffstat (limited to 'source3')
-rw-r--r--source3/client/client.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/source3/client/client.c b/source3/client/client.c
index 6c43a974f2..22d7260b8f 100644
--- a/source3/client/client.c
+++ b/source3/client/client.c
@@ -39,6 +39,7 @@ static pstring username;
static pstring password;
static BOOL use_kerberos;
static BOOL got_pass;
+static BOOL grepable=False;
static char *cmdstr = NULL;
static int io_bufsize = 64512;
@@ -2001,8 +2002,12 @@ static void browse_fn(const char *name, uint32 m,
/* FIXME: If the remote machine returns non-ascii characters
in any of these fields, they can corrupt the output. We
should remove them. */
- d_printf("\t%-15.15s%-10.10s%s\n",
- name,typestr,comment);
+ if (!grepable) {
+ d_printf("\t%-15.15s%-10.10s%s\n",
+ name,typestr,comment);
+ } else {
+ d_printf ("%s|%s|%s\n",typestr,name,comment);
+ }
}
/****************************************************************************
@@ -2012,9 +2017,10 @@ static void browse_fn(const char *name, uint32 m,
static BOOL browse_host(BOOL sort)
{
int ret;
-
- d_printf("\n\tSharename Type Comment\n");
- d_printf("\t--------- ---- -------\n");
+ if (!grepable) {
+ d_printf("\n\tSharename Type Comment\n");
+ d_printf("\t--------- ---- -------\n");
+ }
if((ret = cli_RNetShareEnum(cli, browse_fn, NULL)) == -1)
d_printf("Error returning browse list: %s\n", cli_errstr(cli));
@@ -2029,27 +2035,37 @@ static BOOL browse_host(BOOL sort)
static void server_fn(const char *name, uint32 m,
const char *comment, void *state)
{
- d_printf("\t%-16.16s %s\n", name, comment);
+
+ if (!grepable){
+ d_printf("\t%-16.16s %s\n", name, comment);
+ } else {
+ d_printf("%s|%s|%s\n",(char *)state, name, comment);
+ }
}
/****************************************************************************
Try and browse available connections on a host.
****************************************************************************/
-static BOOL list_servers(char *wk_grp)
+static BOOL list_servers(const char *wk_grp)
{
if (!cli->server_domain)
return False;
-
- d_printf("\n\tServer Comment\n");
- d_printf("\t--------- -------\n");
- cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL, server_fn, NULL);
+ if (!grepable) {
+ d_printf("\n\tServer Comment\n");
+ d_printf("\t--------- -------\n");
+ };
+ cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_ALL, server_fn,
+ "Server");
- d_printf("\n\tWorkgroup Master\n");
- d_printf("\t--------- -------\n");
+ if (!grepable) {
+ d_printf("\n\tWorkgroup Master\n");
+ d_printf("\t--------- -------\n");
+ };
- cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_DOMAIN_ENUM, server_fn, NULL);
+ cli_NetServerEnum(cli, cli->server_domain, SV_TYPE_DOMAIN_ENUM,
+ server_fn, "Workgroup");
return True;
}
@@ -2794,6 +2810,7 @@ static void remember_query_host(const char *arg,
{ "command", 'c', POPT_ARG_STRING, &cmdstr, 'c', "Execute semicolon separated commands" },
{ "send-buffer", 'b', POPT_ARG_INT, &io_bufsize, 'b', "Changes the transmit/send buffer", "BYTES" },
{ "port", 'p', POPT_ARG_INT, &port, 'p', "Port to connect to", "PORT" },
+ { "grepable", 'g', POPT_ARG_NONE, NULL, 'g', "Produce grepable output" },
POPT_COMMON_SAMBA
POPT_COMMON_CONNECTION
POPT_COMMON_CREDENTIALS
@@ -2887,6 +2904,9 @@ static void remember_query_host(const char *arg,
case 'D':
fstrcpy(base_directory,poptGetOptArg(pc));
break;
+ case 'g':
+ grepable=True;
+ break;
}
}