【发布时间】:2018-07-01 16:23:30
【问题描述】:
我希望从 Laravel 执行 psexec 以执行一些远程命令,我想使用 Artisan 控制台来执行此操作(目前)。理想情况下,我想导航到一个 url 并发出命令(我会在这个初始阶段之后实施)。
到目前为止我所拥有的是:
<?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->argument('host');
$bar = $this->output->createProgressBar();
if ($this->confirm('Are you sure you\'d like to restart ' . $host )) {
$this->info('Restarting ' . $host . '...');
}
}
}
如果有人实现了这一点或可以分享一些资源来完成这一点,我将不胜感激。
【问题讨论】:
-
您不能使用
exec或shell_exec将其作为普通命令运行吗?
标签: laravel console laravel-artisan