Questions tagged [shell-exec]

The shell_exec() PHP function provides the ability to run shell commands during the execution of a script.

The shell_exec() function provides the ability to run shell commands during the execution of a script. Other similar functions include, exec(), system(), passthru(), and the use of backticks around the command (``). It is important to note that commands executed this way will be run under the same permissions as the user that started the original process (i.e. calling this from a web page processed by Apache will run this under the same user Apache uses, typically httpd).

This functionality becomes handy when the developer wishes to execute a command which no API, library or extension for PHP exists. Example, a script you are developing needs to display the output of the UNIX vmstat command. PHP does not have visibility into such information, so the use of shell_exec('vmstat'); becomes warranted.

This function can be a security risk and, as such, this function is commonly disabled in shared hosting environments.

1065 questions
-1
votes
1 answer

I want to run a python file from php. The python file contains many package (such as torch, models etc.)

I want to run a python file from PHP. The python file contains many packages (such as torch, models, etc.). I can easily run it using the command line but while calling it from PHP using shell_exec it does not run. The php files looks somewhat…
-1
votes
2 answers

can't connect to specific website using shell_exec and curl php

I am trying to access this (https://www.gearbest.com/cell-phones/pp_009969695587.html) page but with no luck. I get no response...
stefanosn
  • 3,264
  • 10
  • 53
  • 79
-1
votes
1 answer

PHP shell df-h not see external drive

If I run df -h command in the terminal, it is returning with: udev 1,5G 0 1,5G 0% /dev tmpfs 312M 2,0M 310M 1% /run /dev/sda1 109G 7,8G 96G 8% / tmpfs 1,6G 29M 1,5G 2% /dev/shm tmpfs …
benadzs
  • 127
  • 2
  • 13
-1
votes
1 answer

shell_exec doesn't work on Linux server

I'm using youtube-dl.exe on my Windows WAMP server and shell_exec() is working great on Windows, I get the right info from youtube-dl (returns a string). Once the same PHP script is uploaded on my real Linux server it just stops working, even though…
dapgo5
  • 29
  • 4
-1
votes
1 answer

shell_exec() not working on php script

I wants to run shell_exec('youtube-dl -j ' . $url);, but it's not working on my PHP script and return blank array. When I try to run manually through cmd it's working fine. I try localhost and also in my server but both are not working ... i…
mukesh
  • 33
  • 8
-1
votes
1 answer

Executing sudo shell script by php

i am trying to execute pkill command by php script. killengine.sh script runs fine from terminal, both with ./killengine.sh and php restart.php. this is killengine.sh #!/bin/bash sudo pkill -f engine and this is restart.php $out =…
Aleks
  • 45
  • 9
-1
votes
1 answer

Escaping shell_exec

I can run this: echo shell_exec ("tail -n 500 /var/log/website.com_access_log | cut -d' ' -f1 | sort | uniq -c | sort -gr | head -10"); But I can't run this (works in terminal): echo shell_exec ("tail -n 500 /var/log/website.com_access_log |…
Qiao
  • 16,565
  • 29
  • 90
  • 117
-1
votes
1 answer

Why exec() is not working in foreach loop?

See, for testing purpose if I am trying to run PHP exec() statically with only one video file, then its compressing video perfectly(please see first line line). Later when I am compressing dynamically in the loop, then exec function is not working.…
Riyaz Khan
  • 23
  • 1
  • 9
-1
votes
1 answer

Redirect then execute

I'm trying to go to the loading page and then execute the powershell script. But unfortunately I can't get this to work. When I go to the page it automaticaly goes to the script and redirects me to the succes of fail page. I have tried to do a sleep…
T.Strever
  • 3
  • 1
  • 3
-1
votes
1 answer

which path should be given in shell comand? relative path or diretcory path?

For eg: I am executing a shell command: "ffmpeg -i input.flv -ss 00:00:14.435 -vframes 1 out.png" here input.flv path should be like -> images\input.flv or D:\wamp\www\proj_name\public\images\input.flv ?
Always_a_learner
  • 4,585
  • 13
  • 63
  • 112
-1
votes
1 answer

Unable to run inkscape in PHP shell_exec() command

I have a design tool extension that is used on a website I'm working on. The design tool uses inkscape command line to export images. There is a php interface to work with the command line operations which ultimately calls shell_exec($inkscapeCmd).…
spencerready
  • 178
  • 1
  • 10
-1
votes
1 answer

FFMPEG play an overlay video

Hello everyone, I'm struggling hours on placing an image over a video (overlay) and to play the output directly in the web browser (I have FFMPEG installed on the server). Here is what I have : $output = shell_exec($command); …
Chris
  • 93
  • 1
  • 6
-1
votes
1 answer

Running macports-installed programs from PHP shell_exec

I have installed antiword on my Mac (OS X El Capitan) using Macports: sudo port install antiword I would now like to use it from within a PHP program on a webserver in order to be able to convert Word Document files for use in my web application.…
xgretsch
  • 1,294
  • 13
  • 15
-1
votes
1 answer

How to use the function shell_exec() PHP

I have a problem with the function shell_exec(), i've tried everything but I don't know where is the problem. I have this php program that verificates if you are logg in or not, I wanted to use a cookie but i'm not allowed in the apache server of…
-1
votes
2 answers

How to 'output' from a php script called by exec or shell_exec?

I have this line of code to execute a background task (convert several pngs to jpg) exec("nohup path/to/php path/to/convertToJpg.php >> path/to/convert_to_jpg.log > /dev/null &"); Now I am writing the convertToJpg.php script and I can't figure out…
Joshua Goossen
  • 1,714
  • 1
  • 17
  • 36