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

php shell_exec on my ubuntu server does not run the command! why is that so?

This is driving me crazy. After a lot of tests, I managed to successfully run the following .sh file in the terminal and it worked perfectly as I expected. adt -package -target apk -storetype pkcs12 -keystore $AND_CERT_FILE -storepass $AND_CERT_PASS…
Peyman
  • 367
  • 1
  • 4
  • 11
-2
votes
1 answer

Sed doesnt work with shell_Exec()

I have a file that looks like this: #EXTM3U #EXTINF:-1 tvg-id="A&E [Brazil]" tvg-name="A&E **" tvg-logo="http://url/2dhy3yl" group-title="FILMES & SERIES",A&E ** http://url/live/Enrico/321/6660.ts #EXTINF:-1 tvg-id="A E [Brazil]" tvg-name="AeE"…
-2
votes
2 answers

Read content image and store it into a file with `PHP` and `CURL` and executable commands

I have a dynamic image as PHP file:
Nabi K.A.Z.
  • 9,887
  • 6
  • 59
  • 81
-2
votes
1 answer

PHP exec(), shell_exec(), proc_open() & powershell working in CMD but not in browsers

Below scripts working fine in CMD window but not in browsers. Below scripts are in 'front.php', win10's command window command 'php front.php' doing nice but http://localhost/blahblah/front.php sucking me by not triggering 'back.php'. Spent almost…
Raju
  • 75
  • 10
-2
votes
2 answers

codes within php tags doesn't get executed

I upgraded my system from Ubuntu 15.10 to Ubuntu 16.04 and now the code doesn't execute within php tags even though I install Apache2 and Php again. I only see the form as shown here and don't see the output of ls -ltr
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408
-2
votes
1 answer

Is there a way for PHP to remain in the same directory between multiple backtick commands?

I am planning to execute an operation using the backtick operator in a foreach loop. I want to change to the desired directory before the loop, and then iterate without needing to change the directory back. The following simple test seems to show…
dlolsen
  • 132
  • 1
  • 6
-2
votes
3 answers

Rename file names from zip in php

I have created zip files using shell_exec function. I am trying to rename files from created zip using shell_exec function. Any idea about it?
Digambar
  • 9
  • 6
-2
votes
1 answer

I need to send email from my website in PHP. How can I do this?

I need to send email from my website in PHP. By requirement, I can not use the built in mail() PHP function (so no sendmail). I downloaded 'mail' on my unix server and through a function in PHP should be able to connect in order to send emails. The…
Davide
  • 1,931
  • 2
  • 19
  • 39
-2
votes
2 answers

Underscore in php shell_exec

i try to execute a grep command inside a php shell_exec. And it works fine besides it fails when i have a underscore in the search word. I can not seem to figure out why this fails because of a underscore since, a grep command with a underscore in…
PatrickSH
  • 27
  • 4
-2
votes
1 answer

php and ffmpeg from command line in windows - not working, nothing returns

I'm trying to execute ffmpeg within a website and it never output's a file, nothing return's, I have tried it with parameters -version and that works fine. I can copy and paste the main command into dos and it also works fine. I'm stuck, I have…
user3725395
  • 145
  • 2
  • 13
-2
votes
1 answer

How to Create zip file in PHP using shell command on linux server

this is the command that actually i want to run using PHP in Linux server. shell_exec(" zip -r abc.doc xyz.doc > foo.zip "); Using this command i script create damanged zip file, so can anyone help me to make it proper.
user1885136
  • 3
  • 1
  • 2
-3
votes
1 answer

syntax error in commands

I have an iframe to send the commands from control panel when the user clicks the button. Using the code below, nothing happens with the button when the user clicks as there is a syntax error in the code. $items['googledotcom'] = array ( …
NewPHP
  • 608
  • 2
  • 15
  • 28
-3
votes
1 answer

need help to understand the code

ProcessBuilder pb = new ProcessBuilder("myshellScript.sh", "myArg1", "myArg2"); Map env = pb.environment(); env.put("VAR1", "myValue"); env.remove("OTHERVAR"); env.put("VAR2", env.get("VAR1") + "suffix"); …
-4
votes
1 answer

PHP and background processes

I am developing a mass-mailing system. At a time we send 2-4K emails, the email contacts are imported using PHPexcel library at same quantity of emails. Last night when we are sending 2k emails we get the "500 internal server" error. I think I…
siddhesh
  • 598
  • 6
  • 19
-4
votes
2 answers

PHP shell_exec wait for script to done?

I have a PHP script that queries a database for a list of jobs to be done and fires off other PHP scripts based on what it finds in the database (basically a process queue). Some of the scripts that the queue runner script executes may take 30…
Melih Büyükbayram
  • 3,100
  • 2
  • 17
  • 16
1 2 3
70
71