ubuntu - Laravel 5 - How to create an Artisan command to execute bash script -


i want artisan command run bash script when executed.

so i've created artisan command using following

php artisan make:command backuplist --command=backup:list

and here backuplist.php

<?php  namespace app\console\commands;  require_once __dir__ . '/vendor/autoload.php';   use illuminate\console\command;   class backupdb extends command {  protected $signature = 'backup:list {name}';  protected $description = 'database backup tool';    public function __construct() {     parent::__construct(); }    public function handle() {     $this->exec('ls -la'); } } 

in handle() exec , shell_exec don't seem work, there alternatives artisan command run bash in shell?

rather use:

$this->exec('ls -la'); 

you can following:

// execute command exec("ls -la", $output);  // print output command $this->comment( implode( php_eol, $output ) ); 

Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -