shell-exec

PHP - shell_execute -change user password

Hi, I need to be able to change the users' password through a web page (in a controlled environment). So, for that, I'm using this code: <?php $output = shell_exec("sudo -u dummy passwd testUser testUserPassword"); $output2 = shell_exec("dummyPassword"); echo $output; echo $output2; echo "done"; ?> My problem is that this script is n...

How do I to properly handle spaces in PHP Shell_exec?

I'm running on win2003 server, PHP 526, via the cmd-line. I have a cmdline string: $cmd = ' "d:\Prog Files\foo.exe" -p "d:\data path\datadir" '; Trying to do this in php code $out = `$cmd`; # note use of backticks AKA shell_exec results in a failure by foo.exe as it interprets the -p arg as "d:\data". However, the same $c...

php shell_exec() through cygwin

I wrote a script that compiles LaTeX code through pdftex. The trouble is that pdftex only runs on linux. I am accomplishing this task with the use of shell_exec(). I don’t really have the ability to set up a linux box as a web server. I have my client computer, but it is behind a firewall that I do not control. I do have control of my ...

Exec() in PHP on Windows without opening up cmd.exe Security weakness ?

Hi, I have the requirement for a web script to execute an exe file and then return the results on the exe to the web request. I can either echo back the result of the exe or modify the exe to save it's results to a file, and then read the file to echo back the web request. The problem is that using php under IIS all exec() shell_execu...

Zipping files through shell_exec in PHP: problem with paths.

I'm working on a web backup service part of which allows the user to download a zip file containing the files they have selected from a list of what they have backed up. The zipping process is done via a shell_exec command. For this to work I have given the apache user no-password sudo privileges to the zip command. My problem is, sin...

error executing shell script in PHP

I am trying to execute a shell command via: <php echo shell_execute("tac /home/kusmuk/access-logs/kusmuk.org"); ?> But it does not give any output. What could be the reason? Although it does not work, the following lines work as expected: <php echo shell_execute("ls -al triogrup.com"); ?> //outputs: -rw-r----- 2 root kusmuk 28640 Au...

Calling bash with PHP's shell_exec -- slow.

Hi, I'm using PHP's shell_exec function to call a bash script on my server. shell_exec("bash -x /tesladata/isetools/0-extractbytickerforweb.bash $ticker $isedate > /t24alv2/iseoutput/$ticker-$isedate-$thistime.log &"); Now, I previously had the command running from a CGI script ("bash -x...") and it was much faster (instantaneous). N...

Calling java program dependent on external library

I am trying to call a java program in php to use it with web interface. Java program is dependent on an external lib: commons-cli-1.2.jar So basically I need to export it before calling the java program; but if I export it first as: shell_exec('export CLASSPATH=$CLASSPATH:~/lib/commons-cli-1.2.jar'); then call the java program as: ...

PHP exec_shell using unrar.exe

I'm running the following php code; $output = exec('"D:\TESTDIR\unrar.exe" e "D:\TESTDIR\Icons.rar" -ppassword'); echo $output; Which isn't working... I want it to extract the files into the same directory. If I copy the contents of the exec into a command line prompt it works just fine, so slightly confused. Trying the following; $...

Securing a string before exec()ing it

Hi I have a PHP app which takes a user-inputted $imageurl and does the following: exec('convert "'.$url.'" -thumbnail 80x500 "images/out.jpg"'); Now obviously I have to take some precautions with this to stop users from executing arbitrary code. For example, if the user sets $url to";rm -rf *;" is no good at all. So for starters I h...

Validate if an application is at the server

Hi all, I have an own webserver and for one of my clients I need to be able to search through PDF's. I've asked my hostingprovider to install the xPDF package. Now I've come to testing and I'm calling this line of code in a PHP script: $content = shell_exec('/usr/local/bin/pdftotext test.pdf -'); The only thing is, I'm getting a NULL ...

How to get shell_exec to run on IIS 6.0

The Problem I have a PHP script that uses shell_exec to run a pdf-to-text converter. To simplify the problem I've created a short script that uses shell_exec to just echo the output of the dir command. <?php $cmd = 'C:\\WINDOWS\\system32\\cmd.exe /c '; echo shell_exec($cmd.' dir'); ?> When I run this on my Apache server, everything w...

PHP shell_exec HOW TO CHANGE LINUX PASSWORD

I Need some serious help guys i got locked out from my sever, some hacker change my password however he wasnt able to hack the root account i still have access but its not enabled in ssh so i need access to my account in linux i only have access to http on my server i want to know how possible i can change my password via php. i am havin...

running bash scripts in php

I have two computers. On the first computer I have apache running with all my web code. On the second computer I have large amounts of data stored with a retrieval script (the script usually takes hours to run). I am essentially creating a web UI to access this data without any time delay. so I call: exec("bash initial.bash"); this i...

shell_exec() in PHP

<?php // Execute a shell script $dump = shell_exec('bigfile.sh'); // This script takes some 10s to complete execution print_r($dump); // Dump log to screen ?> When the script above is executed from the browser, it loads for 10s and the dumps the output of the script to the screen. This is, of course, normal. But if I want the dat...

System_Daemon and shell_exec

Hey Everyone, I've set up a daemon (daemon.php) using PEAR's System_Daemon which waits for something to appear in the database. Once something is there, the daemon gets enough information and sends it out to another script (execute.php) using the shell_exec command this way I'm not worried about waiting for a response and holding up the...

shell_exec() and exec() Doesn't Show The Output

shell_exec(): I'm doing a PHP site that uses a shell_exec() function like this: $file = "upload/" . $_FILES["file"]["name"]; $output = shell_exec("leaf $file"); echo "<pre>$output</pre>"; Where leaf is a program that is located in the same directory of my script, but when I tried to run this script on the server, I just got nothing....

Excuting Java JAR from PHP will not work

I have a java program that generates an HTML file. The Java program takes two input parameters: file1 and file2, the output file is specified by the "--file=". When executed from the command line (UNIX, Mac OS 10.6.2) it looks like this: "java -jar program.jar http://my.testsite.com/test1.html http://my.testsite.com/test2.html --file=...

shell_exec with "svnadmin verify" returns nothing

Hi, I want to give output of svnadmin verify command from shell_exec() var_dump(shell_exec('/usr/bin/svnadmin verify /Users/osman/Desktop/SVN/name')); But it returns 'null'. How can i access the response of svnadmin verify ? Im working with PHP 5.3.2 on Mac OS X Snow Leopard ...

php shell_exec executing java program

In PHP code I try to execute Java program using shell_exec but I get empty line. When I tried to execute program in bash: #bin/bash echo "aaa" I get "aaa" but when i tried to execute the same file with #bin/bash java MainApp I got empty line This is the java code public class MainApp{ public static void main(String[] a...