/** * Run the operation */ public function execute() { $this->status(Phase::ENVIRONMENT()); $this->shell_type = $this->shell->getShellType(); $this->logger->debug("Remote shell is identifying as " . $this->shell_type->value()); foreach ($this->variables as $key => $value) { switch ($this->shell_type) { // Bourne-shell compatibles default: $cmd = 'export ' . $key . '="' . $value . '"'; break; // C-shell compatibles // C-shell compatibles case ShellType::CSH(): case ShellType::TCSH(): $cmd = 'set ' . $key . '="' . $value . '"'; } $this->output($this->shell->sendSmartCommand($cmd, false)); } }
/** * Set the PS1/prompt variable on the server so that smart commands will work * * @param string $marker Leave blank to use a random marker * @param ShellType $shell_type Will auto-detect is omitted * @param int $timeout Time in seconds before giving up waiting for a response */ public function setSmartConsole($marker = null, ShellType $shell_type = null, $timeout = 15) { // Set the smart marker with a timestamp to keep it unique from any references, etc $this->smart_marker = $marker ?: '#:MKR#' . time() . '$'; if ($shell_type === null) { $shell_type = $this->getShellType(); } switch ($shell_type) { // Bourne-shell compatibles default: $this->sendln('export PS1="' . $this->smart_marker . '"'); break; // C-shell compatibles // C-shell compatibles case ShellType::CSH(): case ShellType::TCSH(): $this->sendln('set prompt="' . $this->smart_marker . '"'); break; } //$this->readUntilEndMarker($this->smart_marker, $timeout); $this->waitForContent(1, $timeout); }