===================================================================== Send Command =====================================================================
193731
function send_command(RequiresSession, Command, Parameters, callback) {

			// Check for requirements.
			if (RequiresSession && !Member.session_id) {
				if (callback) { callback(Error('No existing session found. Login required.'), null); }
				return;
			}

			// Start a new transaction.
			var transaction_id = 'TX-' + unique_id();

			// Set up the one time response handler.
			Socket.once(Command + '.' + transaction_id,
				function(Err, Response) {
					if (callback) { callback(Err, Response); }
					return;
				});

			// Clone the command parameters and mark it with our control structure.
			var parameters = JSON.parse(JSON.stringify(Parameters));
			parameters.control = {
				transaction_id: transaction_id,
				session_id: Member.session_id
			};

			// Invoke the function.
			Socket.emit(Command, parameters);

			return;
		}
157312
function(command) {
      var t = this;
      t.shellCmd = ChildProcess.exec(command, function(err, stdout, stderr) {
        if (err) {
          var outstr = 'exit';
          if (err.code) {
            outstr += ' (' + err.code + ')';
          }
          if (err.signal) {
            outstr += ' ' + err.signal;
          }
          t._output(outstr);
          return null;
        }
        if (stdout.length) {
          t._output(stdout);
        }
        if (stderr.length) {
          t._output(stderr);
        }
        t.shellCmd = null;
        t._output(CONSOLE_PROMPT);
      });
      return null;
    }
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
148034
async def send_cmd(self, cmd, loop=None):
        """"""
        _LOGGER.info("Send cmd = %s", cmd)

        if cmd not in COMMANDS and cmd not in range(0, 999):
            _LOGGER.error("Unknown command")
            raise PyMediaroomError("Unknown commands")

        keys = []
        if cmd in range(0, 999):
            for character in str(cmd):
                keys.append(COMMANDS["Number"+str(character)])
            if len(keys) < 3:
                keys.append(COMMANDS["OK"])
            self.current_channel = cmd
        else:
            keys = [COMMANDS[cmd]]

        try:
            async with timeout(OPEN_CONTROL_TIMEOUT, loop=loop):
                async with self.lock:
                    _LOGGER.debug("Connecting to %s:%s", self.stb_ip, REMOTE_CONTROL_PORT)
                    stb_recv, stb_send = await asyncio.open_connection(self.stb_ip,
                                                                       REMOTE_CONTROL_PORT,
                                                                       loop=loop)
                    await stb_recv.read(6)
                    _LOGGER.info("Connected to %s:%s", self.stb_ip, REMOTE_CONTROL_PORT)

                    for key in keys:
                        _LOGGER.debug("%s key=%s", cmd, key)
                        stb_send.write("key={}\n".format(key).encode('UTF-8'))
                        _ = await stb_recv.read(3)
                        await asyncio.sleep(0.300)

        except asyncio.TimeoutError as error:
            _LOGGER.warning(error)
            raise PyMediaroomError("Timeout connecting to {}".format(self.stb_ip))
        except ConnectionRefusedError as error:
            _LOGGER.warning(error)
            raise PyMediaroomError("Connection refused to {}".format(self.stb_ip))
306600
function bridgeCommand(command,cb){
    if(!connected) return setImmediate(function(){
      cb('killed');
    });

    if(!connected.pings) connected.pings = {};
    var id = ++pingid;
    var timer;
    connected.pings[id] = function(err,data){
      clearTimeout(timer);
      delete connected.pings[id]
      cb(err,data);
    };
    connected.send({command:command,cb:id});
    // set 5 second time limit for callback.
    timer = setTimeout(function(){
      cb("timeout");
    },5000);
  }
222233
function(command, args){
		// message in JSON Format
		var messageJson = {
			"command": _.union([command], args)
		}
		var message = JSON.stringify(messageJson)
		this.socket.write(message + "\n");
	}
1156596
def send_command(cmd, content, options)
      begin
        options ||= {}
        cmd = { :name => cmd, :content => RightScale::AuditProxy.force_utf8(content), :options => options }
        EM.next_tick { @agent_connection.send_command(cmd) }
      rescue Exception => e
        $stderr.puts 'Failed to audit'
        $stderr.puts Log.format("Failed to audit '#{cmd[:name]}'", e, :trace)
      end
    end
1090467
@Override
    public boolean sendCommand(String command) {
        try {
            sendCommand2(command);
        } catch (Exception ex) {
            logger.error("Could not run command " + command, ex);
            return false;
        }
        return true;
    }
674221
function sendCommand(js,cb){
    if(!js) return stream.log('send command got no command!',js);
    var id = ++stream.inc;
    if(!js.id) js.id = 0;// default input id.

    var start = Date.now();
    var timeCallback = function(err,js){
      js.basetime = Date.now()-start;// decorate performance time.
      if(cb) cb(err,js)
    }

    if(js.timeout == undefined) js.timeout = 10000;
    else if(js.timeout < 0) {
      js.timeout = 60000;// 60 seconds max timeout
    } else if(js.timeout > 60000){
      js.timeout = 60000; 
    }
    
    var timeout = js.timeout;
    setTimeout(function(){
      if(stream.callbacks[id]) {
        // make reply js
        js.type = "reply";
        js.err = "base timeout in "+timeout+" ms";
        js.timeout = timeout;
        js.timeerror = true;
        js.from = js.to;
        delete js.to;
        timeCallback(true,js);
      }
    },timeout);

    stream.callbacks[id] = {id:js.id,cb:timeCallback};
    js.id = id;

    if(stream.inc > maxId) stream.inc = 1;

    js.type = "command";
    toBoard.write(js);
  
    return js;
  }
23941
public void write(Command cmd)
        throws IOException, IllegalArgumentException {
        //we delete the initial reply when the first command is sent
        if (cmd == null) {
            throw new IllegalArgumentException("null argument: cmd");
        }
        if (logger.isDebugEnabled()) {
            logger.debug("Control channel sending: " + cmd);
        }
        writeStr(cmd.toString());
    }
1282691
def _simple_command(self, command, arg=None, **kwargs):
    """"""
    self._protocol.send_command(command, arg)
    return self._protocol.handle_simple_responses(**kwargs)
1119157
def __send_command(self, command, command_string=b'', response_size=8):
        
        if command not in [const.CMD_CONNECT, const.CMD_AUTH] and not self.is_connect:
            raise ZKErrorConnection("instance are not connected.")

        buf = self.__create_header(command, command_string, self.__session_id, self.__reply_id)
        try:
            if self.tcp:
                top = self.__create_tcp_top(buf)
                self.__sock.send(top)
                self.__tcp_data_recv = self.__sock.recv(response_size + 8)
                self.__tcp_length = self.__test_tcp_top(self.__tcp_data_recv)
                if self.__tcp_length == 0:
                    raise ZKNetworkError("TCP packet invalid")
                self.__header = unpack('<4H', self.__tcp_data_recv[8:16])
                self.__data_recv = self.__tcp_data_recv[8:]
            else:
                self.__sock.sendto(buf, self.__address)
                self.__data_recv = self.__sock.recv(response_size)
                self.__header = unpack('<4H', self.__data_recv[:8])
        except Exception as e:
            raise ZKNetworkError(str(e))

        self.__response = self.__header[0]
        self.__reply_id = self.__header[3]
        self.__data = self.__data_recv[8:]
        if self.__response in [const.CMD_ACK_OK, const.CMD_PREPARE_DATA, const.CMD_DATA]:
            return {
                'status': True,
                'code': self.__response
            }
        return {
            'status': False,
            'code': self.__response
        }
975273
@Override
    public String sendCommand2(String command) throws IOException {
        String str = null;
        SshConnection ssh = null;
        try {
            ssh = SshConnectionFactory.getConnection(config.getGerritHostName(),
                    config.getGerritSshPort(), config.getGerritProxy(), config.getGerritAuthentication());
            str = ssh.executeCommand(command);
        } catch (Exception ex) {
            throw new IOException("Error during sending command", ex);
        } finally {
            if (ssh != null) {
                ssh.disconnect();
            }
        }
        return str;
    }
756123
function runCommand(cmd, args, cb) {

	// set locale so we can be sure of consistency of command execution
	const env = extend(process.env, { LANG: 'en', LC_ALL: 'en', LC_MESSAGES: 'en' });

	const argArray = Array.isArray(args) ? args : args.split(' ');

	const s = spawn(cmd, argArray, {
		stdio: ['ignore', 'pipe', 'pipe'],
		env
	});

	let stdout = '';
	s.stdout.on('data', (data) => {
		stdout += data;
	});

	let stderr = '';
	s.stderr.on('data', (data) => {
		stderr += data;
	});

	s.on('error', (error) => {
		cb(error, null, stdout, stderr);
	});

	s.on('close', (code) => {
		cb(null, code, stdout, stderr);
	});
}
921137
def send_command(self, *args, **kwargs):
        
        if len(args) >= 1:
            command_string = args[0]
        else:
            command_string = kwargs["command_string"]

        # If changeto in command, look for '#' to determine command is done
        if "changeto" in command_string:
            if len(args) <= 1:
                expect_string = kwargs.get("expect_string", "#")
                kwargs["expect_string"] = expect_string
        output = super(CiscoAsaSSH, self).send_command(*args, **kwargs)

        if "changeto" in command_string:
            self.set_base_prompt()

        return output
70823
def send_command(self, obj, command, *arguments):
        
        index_command = obj._build_index_command(command, *arguments)
        self.chassis_list[obj.chassis].sendQueryVerify(index_command)
316971
def send(command, data):
    
    global _lock
    try:
        _lock.acquire()
        data = data.encode('utf8')
        assert len(data) < 1000000, 'Command too long'
        msg = b'%b%06d%b' % (command.value, len(data), data)
        logging.getLogger(__name__).debug('Sending command, data: [%s]' % msg)
        _out_file.write(msg)
        _out_file.flush()
    finally:
        _lock.release()