【问题标题】:Run external command via Laravel Artisan Console通过 Laravel Artisan 控制台运行外部命令
【发布时间】: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 . '...');
        }
    }
}

如果有人实现了这一点或可以分享一些资源来完成这一点,我将不胜感激。

【问题讨论】:

  • 您不能使用execshell_exec 将其作为普通命令运行吗?

标签: laravel console laravel-artisan


【解决方案1】:

我找到了我的答案The Process Component in Symphony

【讨论】:

    猜你喜欢
    • 2015-04-06
    • 2016-05-09
    • 2022-06-14
    • 1970-01-01
    • 2016-04-10
    • 2017-10-14
    • 1970-01-01
    • 1970-01-01
    • 2019-02-17
    相关资源
    最近更新 更多