title: Run external command via Laravel Artisan Console
body: <p>I'm looking to execute <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/psexec" rel="nofollow noreferrer">psexec</a> from Laravel to execute some remote command and I'd like to use the Artisan Console to do so (for now). Ideally, I'd like to navigate to a url and the command would be issued (something i'd implement after this initial stage).</p>
  
  <p>What I have so far is:</p>
  
  <pre><code>&lt;?php
  
  namespace App\Console\Commands;
  
  use Illuminate\Console\Command;
  
  class RestartSplunk extends Command
  {
      /**
       * The name and signature of the console command.
       *
       * @var string
       */
      protected $signature = 'splunk:restart {host}';
  
      /**
       * The console command description.
       *
       * @var string
       */
      protected $description = 'Restart Splunk instance on given host';
  
      /**
       * Create a new command instance.
       *
       * @return void
       */
      public function __construct()
      {
          parent::__construct();
      }
  
      /**
       * Execute the console command.
       *
       * @return mixed
       */
      public function handle()
      {
          $host = $this-&gt;argument('host');
  
          $bar = $this-&gt;output-&gt;createProgressBar();
  
          if ($this-&gt;confirm('Are you sure you\'d like to restart ' . $host )) {
              $this-&gt;info('Restarting ' . $host . '...');
          }
      }
  }
  </code></pre>
  
  <p>If someone has implemented this or can share some resources to accomplish this it'd me much appreciated.</p>