EchoLogic EchoLogic - 1 year ago 185
Python Question

How to run python script with Laravel's command fire method?

I have a need to execute a Python script from a Laravel Command, but I can't find any methods in

to complete my task.

I want to run this command via the console:

C:\Python34\python H:\myapp\app\python\

To do so, I tried the following in my commands

public function fire()
$this->call('C:\Python34\python H:\myapp\app\python\');

public function fire()
$this->line('C:\Python34\python H:\myapp\app\python\');

None of them work, as Laravel is expecting me to be calling another Laravel command from them. What is the best way to call a simple python script via a Laravel Command?

Answer Source

try PHP exec function:

exec('C:\Python34\python H:\myapp\app\python\');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download