PHP - Execute File On Server Exec()
guys i wand to execute a program on my seerver, i use the
$_SESSION['tmp'] = exec("print.exe", $results); and works but when i change the directory $_SESSION['tmp'] = exec("d:\\print\\user1\\print.exe", $results); dont work, works only in root directory, is any way to set the execution to other directorys?? thanks Similar TutorialsHi Guys, how to execute batch file in wamp server php code. Could you please help on that.
Hey, all... Hoping someone can point me in the direction to get this script to execute a little quicker (looking for several seconds to be shaved). I've got a script that takes info from a form, dumps into a DB, then runs a shell command (custom app) that takes the info from the DB, puts it into a specific (and different for each client) spreadsheet, gets some other values, and puts those in the database. When i execute the command from a cmd prompt, it finishes in less than a second. However, when I run it from PHP, it takes anywhere from 9 - 15 seconds to get to the next page. I've watched it in task manager, and the file i'm running is open for "what appears to be" the entire length of time before the results page appears (although, i realize that technically it's not). why could it be taking so much longer from PHP than it does from the CLI? can you think of a way to get it to run quicker? I don't think it's a PHP coding issue, but more of a permissions issue, but I can't think of anything else to try at this point... Hi all, I am a newbie to PHP. I'm trying to execute a program from my PHP script by calling the exec() function of PHP. It works fine when i try it from command line, or execute the script in command line. But when i call it from a php script in my apache, it does nothing. No errors are thrown. What i get in return is only an empty array. i'm using Ubuntu 11.10 and Apache 2.2 with PHP 5.3.3 thanks for helping me. I have a PHP script containing the function exec which works fine in PHP 4 in IIS 7 on Windows 7. However this function does not work in PHP 4 in IIS 5 on windows server 2003. But I have to make it work there because that is what we have on our web server. Can someone provide a solution? I am trying to get a php script on a remote server to execute on my server but im having problems getting it to work, and i am not sure if it is even feasible i have had a look on google but i cant find much information on it. This is what i have tried up to now I saved a php script as a txt file on y remote server. then used file_get_contents on my home server $curl_scraped_page = file_get_contents('http://www.remote_server.com/script.txt'); the content of the txt file was $sum = 1+1; then i tried to echo $sum on the home server but i did not work can anyone point me in the right direction or is what i am trying to do even feasible? Thanks in advanced Code: [Select] <?php exec('java -jar/MicroChatServer.jar',$output); print_r($output); ?> Hello frds......... I have chat prg. jar file and I have to integrate this chat in a PHP website uses Wampserver.... I try above code but it display "Array()" instead of execute jar file. What should I do???? Any idea?????????????// Hello, I need to execute a remote web page (distant server) every X seconds. How is it possible and is there any way to make it look exactly like a normal user request through a standard browser like Firefox, Chrome, etc. ? I've heard of cURL, but it seems that servers may block it, so there must be somehow a difference between a usual user request and a cURL execution. Thank you for any help ! :-) Matthew 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>"; } ?> Hello. The title is a little confusing, but: What I am trying to do is build a simple CMS where all requests are routed through the root index.php file. This file will be where all constants are defined and importantly where the database connection is estabilished. There will be a folder where template files will reside and, based on the URI, a template file will be included into the root index.php file. Here's some code: Code: [Select] <?php //Sets the database connection and defines some constants require ( "includes/config.php" ); //Where I will place the core functions of the CMS, one being the navigation builder require ( "includes/functions.php" ); //Home page template file require ( "views/cms/index.php" ); ?> So as you can see, I want to be able to call the navigation builder function, called "getMenuItems();", from the home page template. However, I get the following error: Code: [Select] Fatal error: Call to undefined function getMenuItems() in C:\wamp\www\cms\views\cms\index.php on line 3 How can I access functions that have been defined in the "includes/functions.php" file, from the required template file "views/cms/index.php"? If you need anything else explaining then please ask. If this has already been posted, I apologise in advance! I have searched Google and the forums but nothing turned up. Chris I have a PHP web system that store in a windows server. In the system, there is a function for user to upload files to another server (Shared server in Unix). When i try to upload a file, it gives warning: Warning: move_uploaded_file(\\unixserver/sharedfolder/upload/test.txt) [function.move-uploaded-file]: failed to open stream: Permission denied in C:\wamp\www\upload\index.php on line 40 For your information, my username has been assigned in xxx's group that has access to read and write on that folder. Besides, i'm able to open,create and delete files on that folder's server manually (samba). The safe mode setting is off. Does anybody has any idea why this thing happen? I have written a Validation class that checks to see if a file being uploaded to the server meets certain conditions. That works a treat. The next step is to actually upload it to the server and I have an Upload class that can do that. Again, that works perfectly fine. Once the file uploads, I am passing the $location of that of that file to my DB class. The DB class is full of methods that prepare and then execute strings that are SQL queries that are required in other areas of my application. Nothing I have at the moment is suitable for just running an SQL file so I don't know what to do now.. My procedural code, that works, looks like this; $dbh2 = new PDO("mysql:host=localhost;dbname=DB360transfer", $login_user, $login_password); $sql = file_get_contents($path.$new_file_name); $qr = $dbh2->exec($sql);I'm not sure how to replicate this up in a PDO/OOP application. My DB Class script is attached. The run_from_file code starts on line 98. I've left in the other stuff as I suspect the answer has something to do with using the $this or the self:: - but really I have no idea. So my question is, what is the correct syntax for executing a file in OOP? Attached Files DB.php 2.92KB 6 downloads I'm looking to get php to write to file when someone visits one of my sites without javascript.
From the research I've done, it seems that an css hidden, iframe within the noscript tag would work, and the php file would then write to a log.
I just want a simple tick log that increments by 1, but perhaps also lists the user-agent.
My one concern is that I want to include this same code on multiple sites, all of which could be trying to access, and write a tick to the same "no JS log". Is that going to cause problems the way php writes to files?
Can someone help me create the code that will write to this log file, that won't cause errors or problems when multiple sites/visitors could be making writes to the log?
I'm a php noob, so while I can research how to get php to write to a file and save, most of the tutorials don't mention if it would be a safe method to use, if multiple domains were trying to write to that same file, at the same time, and trying to add their own "tick" to increment the number within the flat file.
Extended help that I'm looking for is getting ticks per user-agent/search bot, so bots/web users that visit my pages, that don't run JS, could have ticks by them. eg:
Google Bot: 3
Mozilla Firefox 31.0: 15
Any help on this would be appreciated, or any flaws that you see in this type of tracking, thanks!
Hey everyone, I have an SQL file called "Cype.sql" and I was wanting to have it run when the install feature is going on. However I can't seem to figure out why exactly the code is not working. is it possible to have it run without getting too in depth the PHP coding? I'm not OOP Literate yet. //Connection is opened //While in installation file $sqlFile = "Cype.sql"; if(!file_exists($sqlFile)){ echo "File not found"; } else{ $openFile = fopen($sqlFile, "r"); $tryQuery = mysql_query($openFile); } Now obviously, I'm not the best coder. I've been out of the works of PHP for quite some time now as well. However, I have researched it and found no answers to my issue. Any help would be greatly appreciate. Thank you. Hey. I am wanting to move a couple of files from my current server to another. If i am uploading the file this is fine but if it is already on the server then im not sure how to move it. When uploading I can just use ftp_put($conn_id, $destination_file, $myFile, FTP_BINARY); What i need to do is figure out how to get a hold of the file and store it in $myFile then this would work fine. Is this possible? Cheers This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=352264.0 Or is it all pieced together into one file then executed? I ask because I'm thinking of a weird way to handle errors on my site that would integrate with the interface smoothly without much work on my part. Every page on my site requires template_top.php at the start of the script and template_bottom.php at the bottom. I believe this is a pretty common thing to do, and it standardizes all my menus and interfaces and whatever else, plus it gives me a nice place to deliver messages to the user. What I want to do is something like this simplified example: template_top.php: <?php // layout stuff here try { ?> index.php: <?php require_once('template_top.php'); // a wild error appears! throw new Exception('oh no!'); require_once('template_bottom.php'); ?> template_bottom.php: <?php } catch (Exception $e) { echo 'An error occured! Message: ' . $e->getMessage(); } // layout stuff here ?> So that's where my question comes in. Both template files contain code that, if executed on it's own, is invalid. Pieced together in my pages though, it forms correct code. I'd really like to do this since all I'd have to do if my script encounters a problem is throw an Exception and everything is instantly handled without me having to fight with display issues. If this isn't possible, does anybody have any better suggestions? Anyone know how I can print a file (specifically a PDF) that is stored on the server to the clients computer with a button? I don't want them to be able to view it, just print it. I've done some research and understand that there is no way to print directly without popping up the Windows Print dialog. And that is fine. I just want them to print this file, but not no where it is or be able to type in a URL to access it. Thanks Mike I have a script that uploads my file, but this script requires apache. I want to get this file onto my other server that's running nginx. Is there a way for PHP to write a file to nginx? Alternatively, is there a way for PHP to copy a file from one server to another? Because that will work as well. How do I do this? Hello There , I want to download a file from the server to the computer . How can i do this ?? i found out this code: header("Content-type: image/jpg"); header("Content-Disposition: attachment; filename=test.jpg"); the problem is , what i get is the file that the code was executed from saved in the .jpg format. how can i direct to a specified path to select a certain file then download it . example let's say i have a folder that contains 2 files: download.php and image.jpg how can i download the image.jpg from the server with the Save As window?? Thank You Hello, Ive got a script that downloads a file to my server. I want to be able to download a file from a site such as FileServe using my premium details. Ive tried http://username:password@fileserve.com/file.rar but that dosent work, It just downloads a tiny small 30kb file. Is there a way i can set a cookie or somthing so my script has access to download file using my premium account? Thanks in advance |