FAQ Database Discussion Community


running php shell_exec WITHOUT returning results to browser?

php,linux,shell,shell-exec
Ok i'm having a nightmare with permissions.. I've got /var/www/src/myshell.sh which is executable #!/bin/bash echo "It's working" > /var/www/html/myshell.txt This works fine from the CLI, the txt file is created containing the "It's working" text. But when I try to run it from /var/www/html/test.php <?php $message=shell_exec("/var/www/src/myshell.sh 2>&1"); print_r($message); ?> It...

Saving an image with shell_exec() - using imagejpeg & jpegoptim, with stdin / stdinout

php,shell-exec,jpegoptim
I'm saving an image twice, once when I create it with imagejpeg and then I compress and overwrite with jpegoptim. How may I do this in one swoop, so I'm not saving the image twice? $im = imagecreatefromstring($imageString); imagejpeg($im, 'img/test.jpg', 100); shell_exec("jpegoptim img/test.jpg"); Jpegoptim have stdin and stdout, but I'm...

PHP shell_exec inserts CR character in CURL command, leading to server error 500

php,curl,shell-exec
I use the following test program to retrieve a website's content: <?php function getData( $url, $output ) { // set the path for CURL if (file_exists( '/var/lib')) $curl = 'curl'; else $curl = 'curl.exe'; $curl .= ' --trace trace.txt --header "User-Agent: Some-Agent/1.0" '; echo "\nreading $url...\n"; $buffer = shell_exec( "$curl...

Does executing wget via shell_exec on PHP allows me to close the browser readily without waiting for it to finish the download?

php,linux,wget,shell-exec
I am just wondering (since I do not have my unix platform to test) if I executed a multi command line via the shell_exec() on PHP, am I already safe to close the browser without waiting for it to finish? Because as far as I know, wget will keep downloading...

Why is this shell script not running as expected from PHP?

php,linux,bash,shell,shell-exec
I have this PHP program in /var/www folder to run a shell script and load the HTML file created by that shell script. If I run the shell script manually from command line then it works like charm but when run via PHP program from browser then it only creates...

cant execute python script from php

php,python,linux,exec,shell-exec
here is my code in control.php:- <?php $output = shell_exec("/var/www/script.py"); ?> why i cant run the shell_exec() command when i run the php script..? it should call the script.py and execute the py script.. but, when i run the control.php script.. note that i tried to run a normal program...

shell_exec() function is behaving strangely

java,php,shell-exec
im trying to run a java file through php and shell_exec() is behaving in a strange way. <?php shell_exec("javac Driver.java"); echo shell_exec("java Driver"); ?> This code causes the contents of the java file to be displayed in my web browser and i have no idea why as i am new...

Safe use exec with php

php,exec,shell-exec
How can I use safe exec with php I'm try to do command with exec like this : exec("ejabberdctl register ". $_POST['username'] ." ". $_POST['password']) In this command if any one use in password some thing like this & free -m && free -m ;free -m or 123456 & rm...

Use of sftp with shell_exec php

php,passwords,sftp,shell-exec
I'm trying to get a file from a remote host but it asks me the password and the script is supposed to run without me to type the password. How can I send the password? I have to use shell_exec. <?php $command="sftp [email protected] adress"; shell_exec($command); ?> ...

Why doesn't shell_exec of php work with here?

c#,php,command-line,console,shell-exec
I have a php script and an exe file created using c#. I want php to execute that exe file. I tried to use shell_exec command. But nothing is happening!! Then I tried echo shell_exec("dir"); and it works by displaying the info. Why is it not executing the exe file....

PHP and background processes

php,shell-exec,long-running-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 should develop the new process for...

PHP shell_exec permissions in nginx

php,nginx,permissions,shell-exec
echo shell_exec('ls'); works fine. But trying to copy something: echo shell_exec('cp index.php temp/index.php'); It doesnt show any error, but it doesnt copy. I am using nginx with phpcgi....

php shell_exec character allowed and limit - JSON encoded string as parameter

php,json,command-line-interface,shell-exec
I'm trying to pass a JSON encoded string in php shell_exec function but it seems like it doesn't accept whole string. My code: $exec_string = json_encode( $data ); $command = "php index.php exec_function " . $exec_string; $output = shell_exec( $command );` echo "<pre>$output</pre>; My index.php public function exec_function ( $data...

Giving access to localhost PHP to execute external programs (like Brackets) - Mac OSX

php,osx,apache,shell,shell-exec
I'm trying to find ways to allow some local automation on my Mac (OS X Yosemite) through the use of running PHP on localhost (so that I can easily throw together a simple GUI for whatever it is I'm automating). The problem is getting shell commands to work with the...

PHP passing string with apostrophe to shell_exec

php,mysql,osx,pdo,shell-exec
I’m trying to pass a string (drawn from a PDO query to an MYSQL DB) via PHP shell_exec to a *nix program, in this case xtide. All works fine until I pass a string containing an apostrophe. This works in the Terminal on OSX: [email protected]:~$ tide -l "Nomans Land, Martha's...

Not able to run wkhtmltopdf commad through shell_exec() function in php but same command works on command line

php,wkhtmltopdf,shell-exec
I'm in trouble and that much confused about a php shell_exec command. When the command is execute by PHP I have no error but the execution fails. If I use exactly the same command from a terminal it works. Here's the command : /usr/bin/wkhtmltopdf --lowquality --dpi 300 --encoding utf-8 "/tmp/knplabs_snappyxa9otq.html"...

Running a background process with shell_exec from the PHP built-in webserver

php,shell-exec,php-builtin-server
The PHP built-in webserver does not seem to handle shell_exec()ing background processes properly; the request hangs until the background process is complete, even if it's explicitly placed in the background with &. Example: $ ls runit.php $ cat runit.php <?php echo "Here we are\n"; shell_exec("sleep 5 &"); echo "and the...

PHP Shell_Exec not working with variable

php,shell-exec
I'm trying to pass a variable into shell_exec, I've looked at other tutorials but they still dont help. I want to pass $var[1] into the shell_exec so it will just display this specific file or directory's information $output = shell_exec('ls -l'.$var[1]); ...