PHP - Php Exec Crashing The Launched Program
I'm using a program called Do It Again which is a mouse recorder. I am trying to launch a shortcut to it from my php script. Seems all is okay when I run it as a stand alone program, and is not set to have to be run by the administrator - still when I launch it from my php page I get the windows popup saying the program has crashed. "DoItAgain.exe has encountered a problem and needs to close. We are sorry for the inconvenience."
It's not the program, but something in my code: Code: [Select] $command= 'C:\\xampp\htdocs\poster\dia\\Monty_20.dia'; exec($command); I also tried the following but get the windows popup error: "The Application Failed to Initiate Properly" Code: [Select] $command= ('START C:\\xampp\\htdocs\\poster\\dia\\Monty_20.dia'); Any help would be greatly appreciated. I've been at it for 3 hours now and I'm pulling out what little hair I have left. Similar Tutorials
For example with an IDE to run a program is there a way to put some code in the path and let it tell me where it came from like a referral? $ref = $_SERVER['HTTP_REFERER']; echo("$ref<br>"; Result: https://www.mydomain.com/wp-admin/admin.php?page=lambo As you can clearly see the page that we have entered the code in is referred by the URL here. It tells me that it was last at a word press page /wp-admin/admin-php and I can go to that page and it will be the last page it was at.. So bottom line then if i add this code to the admin page and click the same button i had before.. it will tell me the file that called out the admin page. Baslcaly I am looking for ideas on how to track the page i am now all the way back to the page with the button on it and all intermediate pages that it passes thru to get to the final destination. It seems that to succesfully troubleshoot a fault is to follow the path of the entire job and see if any breaks... Any thoughts or suggestions on how to best do this would greatly be appreciated.
I'm a beginner. I should debug my code from the webserver. When i use arrays and get some error, i generally make "var_dump" or "print_r" to check my data contents. Most of the time, by echo'ing, i can get the errors with related to structure of arrays etc. But when dumped file is too big, webserver crashes. I use shared hosting, so it becomes problem. For example Code: [Select] $html = file_get_html( 'http://www.example.com' ); var_dump($html);I suppose, PHP runs it very long and reserved memory, RAM etc. becomes exhausted. To solve this i sometime write the outputs to txt files. But it would be handy to check the results from browser. What can you recommend me to not to crash server? Thank you I have a payment form that submits its results to Authorize.net. It works on my laptop without an SSL certificate using an Authorize.net test account. But when I transfer this one file over to my GoDaddy account - which has cURL enabled and an SSL certificate - the page crashes when you submit the form results. (Actually you just get a blank page except for echo statements I added?!) If I take out my "Form Validation" block - which uses Regular Expressions - then the form runs on the server?! Someone said it might be that "cURL must have SSL enabled in the build", but that isn't the issue, because I can send data to an HTTPS connection and receive a response back?! Here is a streamlined version of my code... Code: [Select] <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title></title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <link type="text/css" rel="stylesheet" href=".css"> <style type="text/css" > someStyleHere{ font-weight: bold; } </style> </head> <body> <?php // Check Form. echo '*** Checking for Submitted Form ***<br />'; if (isset($_POST['submitted'])){ // Handle Form. echo '*** Form was Submitted ***<br />'; echo '*** Handling Form ***<br />'; // Trim all incoming data. $trimmed = array_map('trim', $_POST); // CHECK BILLING INFORMATION. echo '*** Check for Form Errors ***<br />'; // Check First Name. if (!empty($_POST['firstName'])){ if (preg_match('/^[A-Z \'.-]{2,20}$/i', $_POST['firstName'])){ $firstName = $_POST['firstName']; }else{ $errors['firstName'] = 'Must be 2-20 characters (A-Z \' . -)'; } }else{ $errors['firstName'] = 'Please enter your First Name.'; } // Determine if any errors. if (empty($errors)){ // PROCESS PAYMENT. echo '*** Processing Form ***<br />'; $post_url = "https://test.authorize.net/gateway/transact.dll"; // Output the Response Array to the screen as an HTML Numbered List. echo "<OL>\n"; foreach($response_array as $value){ echo "<LI>" . $value . " </LI>\n"; } echo "</OL>\n"; // Printe Response Code. switch($response_array[0]){ case "1": echo "Response Code: Approved"; break; case "2": echo "Response Code: Declined"; break; } // Do not re-display Payment Form!!! exit(); // ********************************************************************* }// End of PROCESS PAYMENT. }// End of HANDLE FORM. ?> <!-- HTML PAYMENT FORM --> <form id="payment" action="" method="post"> <fieldset> <legend>Billing Details</legend> <ol> <!-- First Name --> <li> <label for="firstName">First Name:</label> <input id="firstName" name="firstName" class="text" type="text" maxlength="20" value="<?php echo $firstName; ?>" /> <?php if (!empty($errors['firstName'])){ echo '<span class="error">' . $errors['firstName'] . '</span>'; } ?> </li> </ol> </fieldset> <!-- Submit Form --> <fieldset id="submit"> <input name="submit" type="submit" value="Place Order" /> <input name="submitted" type="hidden" value="true" /> </fieldset> </form> </body> </html> With my Regular Expressions in, I get this output after submitting the form... Quote *** Checking for Submitted Form *** *** Form was Submitted *** *** Handling Form *** With NO Regular Expressions in, I get this output after submitting the form... Quote *** Checking for Submitted Form *** *** Form was Submitted *** *** Handling Form *** *** Check for Form Errors *** *** Processing Form *** post-string = x_login= and so on... Response Code: Approved (Which means the code is working...) I am at wit's end with this problem... Thanks, Debbie i have a bash script that i was running with cron jobs: #! /bin/bash start=1000 homedir="/home/alin/NetBeansProjects/Fragger2" numberofprocess=`expr $start + $2` i=$start currentnumber=`ps ax | grep index | grep -c php` case "$1" in start) while [ $i -lt $numberofprocess ] do if [ `ps axo cmd | grep index | grep php | grep -c $i` -lt 1 ] ; then /server/php/bin/php $homedir/index.php $i & fi; i=`expr $i + 1` done ;; stop) while [ $currentnumber -ne 0 ] do kill -9 `ps ax | grep php | grep index | awk {'print $1'} | head -n 1`; currentnumber=`ps ax | grep index | grep -c php` done ;; *) echo "Usage : " $0 "start|stop" ;; esac exit 0 and it was working fine, now i'm tring to make it run from a page . if(isset ($_POST['stop'])){ $conn->update("update `links` set `proccess`=0 "); exec("/home/alin/NetBeansProjects/Fragger2/Trans stop 0"); } if(isset ($_POST['start'])){ if(!preg_match("/^[0-9]+$/", $_POST['proccess'])) echo "proccess should be only a number!"; exec("/home/alin/NetBeansProjects/Fragger2/Trans start ".$_POST['proccess']); } and i don't know why it is not working, i have set for this folder all the permision for this folder "chmod -R 777 /home/alin" it doesn't stop running and i can't figure out why i have to kill the procces from the comand line to stop I'm trying to open a batch file in php with these contents: Code: [Select] @echo off java -classpath rscd.jar;lib/mina.jar;lib/xpp3.jar;lib/slf4j.jar;lib/xstream.jar;lib/hex-string.jar; org.rscdaemon.server.Server pause My PHP code is simply Code: [Select] $run = "C:\\Users\\Zorian\\Desktop\\EasyRSC\\Server\\run-win.bat"; echo exec("cmd.exe /c " . $run); It should open up a java applet, instead it just echos: Code: [Select] Press any key to continue . . . Hi guys! I have a php script that works and outputs info: <?php echo exec("uptime"); ?> and another that doesn't output anything: <?php echo exec("MP4Box"); ?> Why?
I figure I’m doing something basic wrong.
$cmd = “at $wtime $wdate <<< “sftp -a -r -P xxx xxx@xxx.xxx.net:”.$file.” /mnt/TRFR” ; the “at” command is never generated atq returns blank. But if I copy the output of the echo from the web page into bash the “at” job gets created.
What am I missing here? Edited April 9, 2020 by Henry_WhoHello, I was just seeing if someone could push me in the right direction. I have a form that uploads items to a database and it also includes uploading images to a directory as a part of that. That all works, but I was thinking for security it'd be best not to leave that directory as 0777 for permissions. In researching this I found the exec() function. I'm still figuring out the relation of who the permissions are associated with and why. All I know is if the directory has 0777 for permissions my script works just fine. I was just seeing if using exec to change the permissions during the process of uploading the images and then change back would be cumbersome and leave open other problems (there won't be any user-based input being passed to that) or if that actually would be the way to go for this. Thanks! -Frank Hey guys i am trying to create a small script using exec() to convert PDF files into images ... The script worked well in the past and for some reasons it staped working. exec('"C:\\Program Files\\ImageMagick-6.7.1-Q16\\convert.exe" -verbose -density 150 D:\\Inetpub\\www.goulet.ca\\Pub\\Web\\new\\media\\other\\'.$value.' -quality 100 -sharpen 0x1.0 D:\\Inetpub\\www.goulet.ca\\Pub\\Web\\new\\media\\pdf_flipbook\\'.$value.'\\img.png', $out); the $out var returns an empty array Hi all.
I tried to execute command below I would like PHP to kick off the following command: Code: [Select] arp -a|sed 's/ /,/g'>arp.csv I also have an executable makeArpFile.sh: Code: [Select] #!/bin/bash arp -a|sed 's/ /,/g'>arp.csv And I have tried executing it in php with the following: $arp = exec("bash makeArpFile.sh", $output, $exit_code); echo("Last line: " . $arp . "\n"); echo("Output: " . $output . "\n"); echo("Exit Code: " . $exit_code . "\n"); /*returns: Last line: Output: Exit Code: 127 */ I also tried just plain old: $arp = exec("makeArpFile.sh", $output, $exit_code); echo("Last line: " . $arp . "\n"); echo("Output: " . $output . "\n"); echo("Exit Code: " . $exit_code . "\n"); /*returns: Last line: Output: Exit Code: 127 */ I can run plain old arp>arp.txt but I really need it formatted in BSD style (arp -a>arp.txt) in order to be able to parse it properly later. Any thoughts? EDIT: for fun I made a useBash.sh script that executed "bash makeArpFile.sh" still no luck. Hello i am trying to execute a linux program for every line of a textarea Code: [Select] $text = $_POST['links']; $text = htmlspecialchars($_POST['links']); $text = nl2br($text); foreach(explode("\n",$text) as $row) { $result = NULL; $command = 'the command'; exec($command,&$result); echo $result[0]."<br>"; } but this always print the result for last line of text area for example if there are 3 lines it print 2 blanks and 1 result... whats wrong?? Hi, I have a java file that needs to be executed from my php script, the command I have in it works perfectly when I execute directly in the command line, but when I execute it from php it returns this: array(0) { } I have tested that the exec works by using antiword, which does return results as expected, but its not working for the code below. But I would much rather use apache tika. Also your thoughts on whether this is good practice please. I am using this to extract text from CV's and store that in the db to be able to search through. I need to extract from: pdf, doc, rtf and docx. this is the only tool I have found that can handle them all. your help on the exec problem and any suggestions will be much appreciated. Code: [Select] <?php exec('java -jar /etc/tika-app-1.0.jar -t /var/www/html/cvdatabase/400001.doc', $output); var_dump($output); ?> have a executable binary to which i pass some dynamic values as hostname,host id,server name,server id and a text field value. Now i call this binary using exec or shell_exec functions in PHP to stimulate Command executions as a admin. But i am able to invoke the binary and not able to use psexec service of windows. I get logs and DB entries successfully but i also have a xml push operation in psexec call that is required. the format is like :: exec($url,$output,$return_var); url is the command path with parameters . output is an out param and return is the code on execution this is executed in PHP and i want this binary to generate the same output as done from CLI . Currently i guess it's a permission issue with shell that disallows psexec call. How do i invoke the binary with psexec access outside PHP on command shell I have set access privilege of Powershell to "unrestricted" so that any script can be executed. Still it hangs up somewhere in th script causing problems in copying XML file. Powershell psexec is required in the process and i need to track down the root cause so that php side scripting of binary is successfull. Please let me know about your ideas in fixing this. I am using google and trying examples ,but i havent got any feasible solution. Hope some expert advice can guide me out of this. I've got a mailing list (uses DadaMail) which provides a perl script (subscribe_email.pl) so that I can pass subscribers to it thorugh a PHP script. Info he http://dadamailproject.com/support/documentation-5_0_1/COOKBOOK-subscriptions.pod.html#command_line_utility___subscribe_email_pl The trouble is I can get it working when variables are passed to it via URL query strings, but when I try to hard-code variables into it it stops working. I can't see any reason for this, it's got me really confused. This works: - Code: [Select] <?php // example usage: - // http://www.domain.com/ds1.php?sendto=user@domain.com&title=Mr&forename=John&surname=Doe&company=None&country=UK if (isset($_GET['sendto'])) { $email = $_GET['sendto']; } if (isset($_GET['title'])) { $title = preg_replace("/[^A-Za-z ]/", "", $_GET['title']); } if (isset($_GET['forename'])) { $forename = preg_replace("/[^A-Za-z\-. ]/", "", $_GET['forename']); } if (isset($_GET['surname'])) { $surname = preg_replace("/[^A-Za-z\-. ]/", "", $_GET['surname']); } if (isset($_GET['company'])) { $company = preg_replace("/[^A-Za-z()\-.& ]/", "", $_GET['company']); $company = str_replace('&', 'and', $company); } if (isset($_GET['country'])) { $country = preg_replace("/[^A-Za-z\-.& ]/", "", $_GET['country']); $country = str_replace('&', 'and', $country); } if (isset($email)) { $exec_command = 'perl ./subscribe_email.pl --list mylist --email '. $email; if (isset($title)) $exec_command .= ' --fields title '. $title; if (isset($forename)) $exec_command .= ' --fields forename '. $forename; if (isset($surname)) $exec_command .= ' --fields surname '. $surname; if (isset($company)) $exec_command .= ' --fields company '. $company; if (isset($country)) $exec_command .= ' --fields country '. $country; exec(escapeshellcmd($exec_command)); } else { echo 'Nothing to do'; } ?> The mail address and all the parameters are passed to the subscribe_email.pl script. But, this doesn't work: - Code: [Select] <?php $subscriber_email = 'user@domain.com'; $subscriber_title = 'Mr'; $subscriber_forename = 'John'; $subscriber_surname = 'Doe'; $subscriber_company = 'None'; $subscriber_country = 'UK'; if (isset($subscriber_email)) { $email = escapeshellcmd($subscriber_email); } if (isset($subscriber_title)) { $title = preg_replace("/[^A-Za-z ]/", "", $subscriber_title); } if (isset($subscriber_forename)) { $forename = preg_replace("/[^A-Za-z\-. ]/", "", $subscriber_forename); } if (isset($subscriber_surname)) { $surname = preg_replace("/[^A-Za-z\-. ]/", "", $subscriber_surname); } if (isset($subscriber_company)) { $company = preg_replace("/[^A-Za-z()\-. ]/", "", $subscriber_company); $company = str_replace('&', 'and', $company); } if (isset($subscriber_country)) { $country = preg_replace("/[^A-Za-z\-. ]/", "", $subscriber_country); $country = str_replace('&', 'and', $country); } if (isset($email)) { $exec_command = 'perl ./subscribe_email.pl --list mylist --email '. $email; if (isset($title)) $exec_command .= ' --fields title '. $title; if (isset($forename)) $exec_command .= ' --fields forename '. $forename; if (isset($surname)) $exec_command .= ' --fields surname '. $surname; if (isset($company)) $exec_command .= ' --fields company '. $company; if (isset($country)) $exec_command .= ' --fields country '. $country; exec(escapeshellcmd($exec_command)); } else { echo 'Nothing to do'; } ?> In the second example, only the list and email parameters are passed, all the others are lost (or ignored). All that's different between the two is the way the variables are inititally set, I can't for the life of me figure out why the second one isn't working . Even stranger, I tried testing with just: - Code: [Select] <?php exec("perl ./subscribe_email.pl --list mylist --email user@domain.com --fields title Mr --fields forename John--fields surname Doe --fields company None --fields country UK") ?> and this doesn't work fully either (again just the list and email parameters are passed). Unfortunately, it's the second method I need to use as it's tagged on to the end of a contact form processing script which initiates the subscription if a checkbox is left ticked...and all variables will be coming from this form script. Any help greatly appreciated! Hy i have a GIT repo on a specific location and i need to exec it. so i tooth it was like exec git reset --hard but it executes the command as it was on the base root location. I need before i execute the command to go to my GIT repo location. Can someone help me out? I read about it here http://www.linuxjournal.com/content/bash-redirections-using-exec and if i get it i need a named pipe... but i don't get how i can do it ~.~ i am a exec newbie. is there a way to excute the system() command here but not wait for it and just let it go in the background? And something that wont boggle down the system too much? Thanks! Code: [Select] $this->db->insert('jukebox', $data); echo '1'; system('ffmpeg -i ' . $id . '.mp3 -acodec libvorbis -aq 60 ' . $id . '.ogg'); Folks, I am running Linux Commands in PHP. I am looping through the Domain list and using the below line in my Script: exec('cp -r '.$source.' '.$destination); I am using this in a Foreach Statment, so only the last Even in the loop getting executed, because, the loop is running too fast so the Linux command does not even get initiated, only the last even in loop goes through. What i have done is, i have added a line after exec(); sleep(30); This gives enough time for Linux command to get executed, but is it efficient way to handle timing liek this? Do i need to use time_limit() or something like that? Cheers Natasha Hi i am running a wamp server on windows 7 i am trying to php exec command to run a command but the output returns 1 does this mean the cmd failed to execute ? Code: [Select] $openssl_cmd = "($OPENSSL mime -sign -signer $MY_CERT_FILE -inkey $MY_KEY_FILE ". "-outform der -nodetach -binary <<_EOF_\n$data\n_EOF_\n) | " . "$OPENSSL smime"." -encrypt -des3 -binary -outform pem $PAYPAL_CERT_FILE"; Hey guys! My current employer contracted someone to create a script for him. (The script itself is to create a serial number for a piece of software) It's just a PHP script that executes a file and retrieves its output. Now I've never worked with exec() in PHP, and I don't have a reliable environment to test it in. I compiled apache2 and php 5.0.4 and set them to run on a Macintosh (10.3.9) in the office, but I'm sure I've missed some crucial setup stage (mainly, I'm missing php.ini. I did a php -i | grep php.ini to find it, and it says it is in /etc/, but when I look in my PHP/etc folder, only pear.conf is there!). PHP and apache both appear to be working fine, though. When I try and run the PHP script that executes the .ELF file, I get a blank page. Is this because I'm running it in OS X? should I be running it in Linux? Also, I don't know how to Enable exec() on my server, or to see if it's enabled. Basically, I just need someone to walk me through the basics of this. The script and executable SHOULD work fine because the contractor got it working fine. Below is the script, and attached is the executable. Thanks! :3 <?php /* inUID = 456890 inSerialNumUID = 123456 inMachineID_s = &6dA-8P@K-Xsq */ $p1 = "456890"; $p2 = "123456"; $p3 = "\&6dA-8P@K-Xsq"; exec("./create_activation_code.elf $p1 $p2 $p3", $output); foreach ($output as $output_str) { echo $output_str."<br>"; } ?> |