rpcclient: return useful error code

Ronan Waide waider at waider.ie
Tue Apr 22 21:50:00 GMT 2003


This patch allows rpcclient to return failure (non-zero) if a
command-line command (i.e. when the -c param is used) fails. Makes it
friendlier for use in scripts, etc.

Cheers,
Waider.

Index: rpcclient/rpcclient.c
===================================================================
RCS file: /cvsroot/samba/source/rpcclient/rpcclient.c,v
retrieving revision 1.180.2.17
diff -u -r1.180.2.17 rpcclient.c
--- rpcclient/rpcclient.c       21 Apr 2003 14:09:02 -0000      1.180.2.17
+++ rpcclient/rpcclient.c       22 Apr 2003 21:47:19 -0000
@@ -628,13 +628,16 @@
         if (cmdstr && cmdstr[0]) {
                 char    *cmd;
                 char    *p = cmdstr;
+               int result = 0;
  
                 while((cmd=next_command(&p)) != NULL) {
-                        process_cmd(cli, cmd);
+                 NTSTATUS cmd_result = process_cmd(cli, cmd);
+                 if (NT_STATUS_IS_ERR(cmd_result))
+                   result = 1;
                 }
 
                cli_shutdown(cli);
-                return 0;
+                return result;
         }
 
        /* Loop around accepting commands */

-- 
waider at waider.ie / Yes, it /is/ very personal of me.

merde says, "i liked [the company] a lot, but i fear the relentless hip of the
    environment may cause me to become caustic and irritable."


More information about the samba-technical mailing list