/*
Send the command the user specified to the debugger and wait for the
response.
195241
function() {
  var exitCode = 0;
  var req = { command: 'disconnect' };

  logger.entry('sendCommand', logger.NO_CLIENT_ID);

  if (evaluated) {
    // No need to send the same command twice.
    logger.log('data', logger.NO_CLIENT_ID, 'Command already sent');
  }
  else {
    // Send the command to the debugger.
    logger.entry('client.reqEval', logger.NO_CLIENT_ID);
    logger.log('parms', logger.NO_CLIENT_ID, 'command:', command);

    client.reqEval(command, function(err, res) {
      // Wait for the response from the debugger
      logger.entry('client.reqEval.callback', logger.NO_CLIENT_ID);
      logger.log('data', logger.NO_CLIENT_ID, 'err:', err);
      logger.log('detail', logger.NO_CLIENT_ID, 'res:', res);
      if (err) {
        // The debugger failed to evaluate the command.
        logger.log('error', logger.NO_CLIENT_ID,
                   'Debugger failed to evaluate command');
        console.error(res.message);
        exitCode = 20;
      } else {
        // The debugger did what we asked!
        console.log('Command evaluated successfully');
      }

      // Regardless of the result, disconnect from the debugger.
      logger.entry('client.req', logger.NO_CLIENT_ID);
      logger.log('parms', logger.NO_CLIENT_ID, 'req:', req);
      client.req(req, function(err, res) {
        logger.entry('client.req.callback', logger.NO_CLIENT_ID);
        logger.log('data', logger.NO_CLIENT_ID, 'err:', err);
        logger.log('detail', logger.NO_CLIENT_ID, 'res:', res);
        if (err) {
          logger.log('error', logger.NO_CLIENT_ID,
                     'Debugger failed to disconnect');
        }

        // Destroy the client, closing the socket.
        logger.entry('client.destroy', logger.NO_CLIENT_ID);
        client.destroy();
        logger.exit('client.destroy', logger.NO_CLIENT_ID, null);
        logger.exit('client.req.callback', logger.NO_CLIENT_ID, null);

        // Time to end.
        process.exit(exitCode);
      });
      logger.exit('client.reqEval.callback', logger.NO_CLIENT_ID, null);
    });

    // Mark that we've now sent the command.
    evaluated = true;
    logger.log('debug', logger.NO_CLIENT_ID, 'evaluated:', evaluated);
  }

  logger.exit('sendCommand', logger.NO_CLIENT_ID, null);
}
1264226
async def debug_command_message(self, message, context):
        

        conn_string = message.get('connection_string')
        command = message.get('command')
        args = message.get('args')
        client_id = context.user_data

        result = await self.debug(client_id, conn_string, command, args)
        return result
619069
def send_command(command)
      SerialPort.open(self.device_path, 9600, 8, 1) do |port|
        # flush anything existing on the port
        port.flush
        flush_read_buffer(port)

        byte_string = command.to_bytes.pack('C*')

        begin
          while byte_string && byte_string.length != 0
            count = port.write_nonblock(byte_string)
            byte_string = byte_string[count,-1]

            port.flush
          end
        rescue IO::WaitWritable
          if IO.select([], [port], [], 5)
            retry
          else
            raise IOError, "Timeout writing command to #{self.device_path}"
          end
        end

        # wait for expected confirmation signals
        got_eot = false
        got_soh = false
        loop do
          begin
            c = port.read_nonblock(1)

            case c
              when "\x04"
                if ! got_eot
                  got_eot = true
                else
                  raise IOError, "Got EOT reply twice from #{self.device_path}"
                end
              when "\x01"
                if got_eot
                  if ! got_soh
                    got_soh = true

                    break
                  else
                    raise IOError, "Got SOH twice from #{self.device_path}"
                  end
                else
                  raise IOError, "Got SOH before EOT from #{self.device_path}"
                end
            end
          rescue IO::WaitReadable
            if IO.select([port], [], [], 3)
              retry
            else
              raise IOError, "Timeout waiting for command reply from #{self.device_path}.  EOT:#{got_eot} SOH:#{got_soh}"
            end
          end
        end
      end

      self
    end
612687
function executeCmd(cmd, debug, quitapp) {
    if (typeof cmd !== 'object') {
        throw new Error('Empty or invalid argument list!');
    }

    let finalcmd = cmd.join(' ');

    if (debug) {
        // debug mode, print to console
        console.log(`Debug shutdown command: ${finalcmd}`)
        if (quitapp) {
            console.log("Now exit app...");
            app.exit(0);
        }
    } else {
        cp.exec(finalcmd, (err, stdout, stderr) => {
            if (err) {
                console.error(err);
                return;
            }
            //console.log(stdout);
            if (quitapp) {
                app.exit(0);
            }
        });
    }
}
54583
function postExec (req, res) {
  let cmd = req.body.cmd;
  let connection = res.locals.connection;
  let parts = myutil.split(cmd);
  parts[0] = parts[0].toLowerCase();
  let commandName = parts[0].toLowerCase();

  // must be in our white list to be allowed in read only mode
  if (req.app.locals.redisReadOnly) {
    if (!isReadOnlyCommand(commandName, connection)) {
      return res.send('ERROR: Command not read-only');
    }
  }

  let args = parts.slice(1);
  args.push(function (err, results) {
      if (err) {
          return res.send(err.message);
      }
      return res.send(JSON.stringify(results));
  });
  // check if command is valid is done by ioredis if called with
  // 'connection.call(command, ...)' and our callback called to handle it
  // but throws Error if called via 'connection[commandName].apply(connection, ...)'
  connection.call(commandName, ...args);
}
525101
def sendQueryVerify(self, cmd):
        
        cmd = cmd.strip()
        self.logger.debug("sendQueryVerify(%s)", cmd)
        if not self.is_connected():
            raise socket.error("sendQueryVerify on a disconnected socket")

        resp = self.__sendQueryReply(cmd)
        if resp != self.reply_ok:
            raise XenaCommandException('Command {} Fail Expected {} Actual {}'.format(cmd, self.reply_ok, resp))
        self.logger.debug("SendQueryVerify(%s) Succeed", cmd)
273563
def send (self, command, *args, **kwargs):
        
        status   = False
        cmdobj   = self._cmddict.create(command, *args, **kwargs)
        messages = []

        if not cmdobj.validate(messages):
            for msg in messages:
                log.error(msg)
        else:
            encoded = cmdobj.encode()

            if self._verbose:
                size = len(cmdobj.name)
                pad  = (size - len(cmdobj.name) + 1) * ' '
                gds.hexdump(encoded, preamble=cmdobj.name + ':' + pad)

            try:
                values = (self._host, self._port, str(cmdobj))
                log.command('Sending to %s:%d: %s' % values)
                self._socket.sendto(encoded, (self._host, self._port))
                status = True

                with pcap.open(self.CMD_HIST_FILE, 'a') as output:
                    output.write(str(cmdobj))
            except socket.error as e:
                log.error(e.message)
            except IOError as e:
                log.error(e.message)

        return status
10542
def send_command():
    

    def verbose(msg):
        """
        print output if verbose is set.
        """
        if options.verbose:
            print(msg)

    options = command_parser()
    msg = json.dumps(vars(options)).encode("utf-8")
    if len(msg) > MAX_SIZE:
        verbose("Message length too long, max length (%s)" % MAX_SIZE)

    # find all likely socket addresses
    uds_list = glob.glob("{}.[0-9]*".format(SERVER_ADDRESS))

    verbose('message "%s"' % msg)
    for uds in uds_list:
        # Create a UDS socket
        sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)

        # Connect the socket to the port where the server is listening
        verbose("connecting to %s" % uds)
        try:
            sock.connect(uds)
        except socket.error:
            # this is a stale socket so delete it
            verbose("stale socket deleting")
            try:
                os.unlink(uds)
            except OSError:
                pass
            continue
        try:
            # Send data
            verbose("sending")
            sock.sendall(msg)
        finally:
            verbose("closing socket")
            sock.close()
670291
function respond(options, content, cache) {
				// cache the response

				var cached = that.responseCache.set(state, queryId, options, cache);

				// send the response back to the client

				cb(null, content, options);

				// log the execution time

				var msg = cached ?
					'Executed and cached user command batch' :
					'Executed user command batch (could not cache)';

				logger.debug
					.data({
						batch: batch.commandNames,
						queryId: queryId,
						durationMsec: duration(),
						options: options,
						dataSize: content.length
					})
					.log(msg);
			}
1122364
def sendCommand(self, command):
        
        command_data = [ord(x) for x in buffer(command)]
        self.hid.write(command_data)
        response_data = ''.join(chr(x) for x in self.hid.read(64))
        response = command.RESPONSE.from_buffer_copy(response_data)
        if response.status != 0:
            raise CommandException(response.status)
        return response
1009365
def send_message(self, message):
        """"""
        self.print_debug_message(message)
        self.socket.send(message)
1134127
def send_command_response(self,
                              source: list,
                              command: str,
                              *args,
                              **kwargs):
        
        args = _json.dumps(args).encode('utf8')
        kwargs = _json.dumps(kwargs).encode('utf8')
        if isinstance(source, list):
            frame = (*source, b'', command.encode('utf8'), args, kwargs)
        else:
            frame = (b'', command.encode('utf8'), args, kwargs)
        if self._run_control_loop:
            self.add_callback(self.command_socket.send_multipart, frame)
        else:
            self.command_socket.send_multipart(frame)
659738
def send_get_command(self, command):
        """"""
        # Send commands via HTTP get
        res = requests.get("http://{host}:{port}{command}".format(
            host=self._host, port=self._receiver_port, command=command),
                           timeout=self.timeout)
        if res.status_code == 200:
            return True
        else:
            _LOGGER.error((
                "Host %s returned HTTP status code %s to GET command at "
                "end point %s"), self._host, res.status_code, command)
            return False
1166317
function makeBeanstalkCommand(command, expectedResponse, sendsData)
{
	// Commands are called as client.COMMAND(arg1, arg2, ... data, callback);
	// They're sent to beanstalkd as: COMMAND arg1 arg2 ...
	// followed by data.
	// So we slice the callback & data from the passed-in arguments, prepend
	// the command, then send the arglist otherwise intact.
	// We then push a handler for the expected response onto our handler stack.
	// Some commands have no args, just a callback (stats, stats-tube, etc);
	// That's the case handled when args < 2.
	return function()
	{
		var data,
			buffer,
			args = argHashToArray(arguments),
			callback = args.pop();

		args.unshift(command);

		if (sendsData)
		{
			data = args.pop();
			if (!Buffer.isBuffer(data))
				data = new Buffer(data);
			args.push(data.length);
		}

		this.handlers.push([new ResponseHandler(expectedResponse), callback]);

		if (data)
		{
			buffer = Buffer.concat([new Buffer(args.join(' ')), CRLF, data, CRLF]);
		}
		else
		{
			buffer = Buffer.concat([new Buffer(args.join(' ')), CRLF]);
		}
		this.stream.write(buffer);
	};
}
1179987
def send_command(self, command, *arguments):
        
        self.api.send_command(self, command, *arguments)
233457
private synchronized void submit(final String command) {
    LOG.log(Level.INFO, "Submit command {0} to {1} evaluators. state: {2}",
        new Object[]{command, this.contexts.size(), this.state});
    assert this.state == State.READY;
    this.expectCount = this.contexts.size();
    this.state = State.WAIT_TASKS;
    this.cmd = null;
    for (final ActiveContext context : this.contexts.values()) {
      this.submit(context, command);
    }
  }
766276
private synchronized void asyncResponse(String command, SocketChannel sc) {
        if (closed) {
            Utils.tryToClose(sc);
        } else {
            Thread thread = new Thread(new ResponseThread(command, sc), "kernel-" + command + "-command-response");

            // We allow a maximum of one outstanding status start or stop command
            Thread oldThread = responseThread.getAndSet(thread);
            if (oldThread != null) {
                oldThread.interrupt();
            }

            thread.start();
        }
    }