protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Fetch a single server.
     $server = ServerList::fetchOne($input->getArgument('server'));
     $output->writeln('<info>Printting</info>');
     // execute the ssh command
     Terminal::execute(sprintf('ssh -l %s %s "cat \'%s\'"', $server->username, $server->address, $input->getArgument('remote-path')));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Fetch a single server.
     $server = ServerList::fetchOne($input->getArgument('server'));
     $output->writeln('<info>Copying your rsa key</info>');
     // execute the ssh command
     Terminal::execute(sprintf('ssh-copy-id %s@%s:', $server->username, $server->address));
     $output->writeln('<info>Done</info>');
 }
Example #3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Fetch a single server.
     $server = ServerList::fetchOne($input->getArgument('server'));
     $sourcePath = $input->getArgument('source');
     $targetPath = $input->getArgument('target');
     $output->writeln(sprintf('<info>Copying from remote to local</info>'));
     Terminal::execute(sprintf('rsync -a -h --progress --delete  %s@%s:%s %s', $server->username, $server->address, $sourcePath, $targetPath));
     $output->writeln('<info>Done</info>');
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Fetch a single server.
     $server = ServerList::fetchOne($input->getArgument('server'));
     // give some info
     $output->writeln(sprintf('<info>Connecting to %s</info>', $server));
     // execute the ssh command
     Terminal::execute(sprintf('ssh -l %s %s', $server->username, $server->address));
     $output->writeln(sprintf('<info>Done</info>', $server));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if ($input->getOption('refresh-cache')) {
         Cache::clear();
         $output->writeln('<info>Cache cleared. Fetching server list</info>');
         $output->writeln('');
     }
     // Fetch a single server.
     $servers = ServerList::fetchMatcing($input->getArgument('pattern'));
     return $input->getOption('hosts-file') ? $this->renderAsHostsFile($output, $servers) : $this->renderAsTable($output, $servers);
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Fetch a single server.
     $server = ServerList::fetchOne($input->getArgument('server'));
     $port = $input->getArgument('port');
     // give some info
     $output->writeln(sprintf('<info>Created tunnel to %s on port %d</info>', $server, $port));
     $output->writeln('<info>Proxy will remain open until you terminate this program</info>');
     // execute the ssh command
     Terminal::execute(sprintf('ssh -N -D %d -l %s %s', $port, $server->username, $server->address));
     $output->writeln(sprintf('<info>Port closed</info>', $server));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Fetch a single server.
     $server = ServerList::fetchOne($input->getArgument('server'));
     $once = $input->getOption('once');
     $lines = $input->getOption('lines');
     $file = $input->getArgument('remote-path');
     $output->writeln(sprintf('<info>Fetching last %d lines from "%s"</info>', $lines, $file));
     $output->writeln(sprintf('<info>%s</info>', $once ? 'Closing file after fetching' : 'Keeping file open'));
     $command = sprintf('tail %s -n %d \'%s\'', $once ? '' : '-F', $lines, $file);
     // execute the ssh command
     Terminal::execute(sprintf('ssh -l %s %s "%s"', $server->username, $server->address, $command));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Fetch a single server.
     $server = ServerList::fetchOne($input->getArgument('server'));
     $count = $input->getOption('count');
     if ($count == 0) {
         $output->writeln('<info>Pinging</info>');
         Terminal::execute(sprintf('ping %s', $server->address));
     } else {
         $output->writeln(sprintf('<info>Pinging %d times</info>', $count));
         Terminal::execute(sprintf('ping -c %d %s', $count, $server->address));
     }
 }
Example #9
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Fetch a single server.
     $server = ServerList::fetchOne($input->getArgument('server'));
     $sourcePath = $input->getArgument('source');
     $targetPath = $input->getArgument('target');
     if (!file_exists($sourcePath)) {
         throw new RuntimeException(sprintf('Invalid path: "%s"', $sourcePath));
     }
     if (!is_readable($sourcePath)) {
         throw new RuntimeException(sprintf('Path not readable: "%s"', $sourcePath));
     }
     $output->writeln(sprintf('<info>Copying from local to remote</info>'));
     Terminal::execute(sprintf('rsync -a -h --progress --delete %s %s@%s:%s', $sourcePath, $server->username, $server->address, $targetPath));
     $output->writeln('<info>Done</info>');
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Fetch a single server.
     $server = ServerList::fetchOne($input->getArgument('server'));
     $ip = gethostbyname($server->address);
     $reverseDns = gethostbyaddr($ip);
     if ($input->getOption('copy-ip')) {
         Process::execute('pbcopy', $ip);
     }
     $output->writeln(sprintf('<info>Information for %s</info>', $server->name));
     $output->writeln('-------------------------------------');
     $output->writeln($this->propertyLine('Data Center', $server->hostingVendor));
     $output->writeln($this->propertyLine('Name', $server->name));
     $output->writeln($this->propertyLine('IP', $ip));
     $output->writeln($this->propertyLine('Reverse DNS', $reverseDns));
     $output->writeln($this->propertyLine('SSH Username', $server->username));
 }
Example #11
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // WARNING: this command is extremely OSX specific.
     if (PHP_OS !== 'Darwin') {
         $output->writeln('<error>This command only works on OSX');
         return -1;
     }
     $server = ServerList::fetchOne($input->getArgument('server'));
     $remote_dir = $input->getArgument('remote');
     $local_dir = str_replace('[server-name]', $server->name, $input->getArgument('local'));
     if (!is_dir($local_dir)) {
         mkdir($local_dir);
     }
     $output->writeln(sprintf('<info>Mounting</info>', $server));
     Terminal::execute(sprintf('sshfs %s@%s:"%s" "%s"', $server->username, $server->address, $remote_dir, $local_dir));
     // open the folder
     if ($input->getOption('open')) {
         system(sprintf('open "%s"', $local_dir));
     }
     $output->writeln(sprintf('<info>Done</info>', $server));
 }