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
2 answers

Is it possible [how?] to blacklist & whitelist shell_exec() commands?

I need to allow the following: shell_exec('whois ' . $domain); BUT I need to disallow everything else, like: shell_exec('ls'); shell_exec('rm -rf /'); shell_exec('sudo service nginx restart'); is it possible to "whitelist" only one shell_exec…
Unamata Sanatarai
  • 6,475
  • 3
  • 29
  • 51
-1
votes
3 answers

PHP cannot find my shell script to execute it with shell_exec()

It turns out my FTP client smushed my shell script, so thanks to everyone who contributed. :) =============================== I'm trying to use PHP to execute a shell script stored in the same directory as my PHP script using exec(), but I get an…
Eva Lauren Kelly
  • 403
  • 1
  • 4
  • 15
-1
votes
1 answer

Why i can't run this jar with shell_exec?

i have create the java class below. This class uses twitter4java api for java-twitter communication. import twitter4j.*; import twitter4j.auth.AccessToken; import java.util.List; public class SearchTweets { public static String API_Key = new…
-1
votes
1 answer

shell_exec mysqli is not working

I'm calling a php script with shell_exec that runs fully operational WHEN called from the terminal (php somescript.php). However, using shell_exec I am able to check the "echo test" I'm issuing inside the script but the database queries with $mysqli…
Fane
  • 1,978
  • 8
  • 30
  • 58
-1
votes
1 answer

Does FFMPEG video in php over shell_exec()

I have timelapse/out.txt"); ?> I would like to create WebM video (timelapse) from the image of a webcam.…
-1
votes
1 answer

hangs when execute powershell script using php

when tring to run powershell script using $out = shell_exec('powershell.exe -command C:\xampp\htdocs\web\ping.ps1 < NUL'); echo $out; it hangs and noting is done , the page just keep loading , that's my simple script ping 8.8.8.8 -t i used…
-1
votes
2 answers

Is there a way not to wait for shell_exec to complete?

I am using shell_exec() to run perl program which takes more than an hour to complete a task by asking users to enter some values. I would like to run shell_exec() as a background program and refresh the summary page back to index page. I found some…
nikki
  • 1
  • 3
-1
votes
1 answer

shell_exec() function is behaving strangely

im trying to run a java file through php and shell_exec() is behaving in a strange way. This code causes the contents of the java file to be displayed in my web browser and…
Blake
  • 151
  • 2
  • 11
-1
votes
1 answer

Apache + PHP Mac OS X 10.0 - does it block diskutil usage in shell_exec()?

I'm on Mac OS X 10 Yosemite, so I'm wondering if others experience the same problem. This code gives you an insight into the problem. Make an index.php file, and this inside:
Taapo
  • 1,785
  • 4
  • 18
  • 35
-1
votes
1 answer

calling php script from within another one

i'm trying to automate a process whereby i have a controlling script that reads through a SQL table for active scripts to process. this controlling script calls several php functions to write log entries, etc to a sql table. the script will also…
-1
votes
1 answer

passing array containing list of urls to shell_exec function in php

I am creating a code that contain shell script in PHP. When I try to run using shell_execute I am not getting actual result. Here's my code: for($i;$i<5;){ $output = shell_exec('./url_integrity_check.sh ' ."'echo $test[$i]'" ); $i++; …
-1
votes
1 answer

Issue regarding shell exec?

Below line is not executing prog.java simply it is executing javac. How can i execute prog.java here? shell_exec('C:\Program Files (x86)\Java\jdk1.6.0_05\bin\javac C:\Apache24\htdocs\uploads\prog.java ');
Abhi_Sharma
  • 51
  • 1
  • 4
-1
votes
1 answer

How can i open terminal through a php command in ubuntu?

I have tried exec, shell_exec, system but they didn't work for me.
Zubair Akber
  • 2,760
  • 13
  • 30
-1
votes
1 answer

Finding the pattern and replacing the pattern inside the file using unix

I need your help in unix.i have a file where i have a value declared and and i have to replace the value when called. for example i have the value for &abc and &ccc. now i have to substitute the value of &abc and &ccc in the place of them as shown…
-1
votes
2 answers

print with shell_exec on Windows 7

Hi would use shell_exec for direct print a PDF file. My code is: When i try to run this code i receive this error: Unable to initialize the device Epson
Jimmy
  • 119
  • 1
  • 2
  • 7
1 2 3
70
71