Computing.Net > Forums > Web Development > Run file on server

Run file on server

Reply to Message Icon

Original Message
Name: Larry21
Date: August 2, 2004 at 21:08:39 Pacific
Subject: Run file on server
OS: Win XP H.E.
CPU/Ram: P4 2.6+HT 512MB
Comment:

Hi,
I'm designing a page that submits a PHP form which in turn executes a file on the server. So basically, when the form is submitted, it runs the file remotely.

My question is if this is the most logical/efficient way to do this? As of now it takes a second or two before the file is run, does anyone know of a method other than this to run a file on the server, which may be a little quicker?

Thanks,
Larry


Report Offensive Message For Removal


Response Number 1
Name: Jamie_McCoy
Date: August 3, 2004 at 08:04:32 Pacific
Subject: Run file on server
Reply: (edit)

Hi, ive been looking for the same thing... run a file on a server after a php request is sent from the webpage

can i have the script

in regards to your queestion, i dont think your going to get much better than a few seconds..

Jaymc.co.nr


Report Offensive Follow Up For Removal

Response Number 2
Name: Larry21
Date: August 3, 2004 at 08:47:59 Pacific
Subject: Run file on server
Reply: (edit)

Here's the basic code that I'm using:

<HTML>
<HEAD>
<TITLE>Webcam Controls</TITLE>

<script type="text/javascript">

function register() {

var keydown=window.event.keyCode;
var keyHit=false;

if (keydown==38)
{
document.keyaction.direction.value="up";keyHit=true;
}
if (keyHit==true)
{
document.keyaction.submit();
}
}


function init() {
document.onkeydown = register;

}

</script>

</HEAD>

<BODY onload="init();">

<form name="keyaction" action="<?php echo $_SERVER['PHP_SELF'];?>" method="POST">
<input type="hidden" name="direction" value="null">
</form


<?php

if (isset($_POST['direction']) && $_POST['direction'] == "up")
{
system("up");
}

</body>
</html>


This JavaScript submits a PHP form when the 'up' arrow key is pressed. The PHP form runs a file on the server called up.exe

If you want to allow multiple actions, then use frames and have the JS call the PHP in the second frame and then the JS page wont have to refresh after each submit. All you do is substitute 'action="<?php echo $_SERVER['PHP_SELF'];?>"' with 'action="phpfile.php"' And put the code in the PHP file. (You can also place the form itself in the PHP file, in which case you'd have to use 'parent.frameone.keyaction.direction.value...etc. Basically direct it to the frame that has the form.

However being that the question has not yet been answered, I'd greatly appreciate it if someone has any ideas.

Thanks

PS- To the best of my understanding, it should not even take one full second to execute a file through a PHP form submit when running it on the server itself (I'd understand some delay if it were being used on the net- as it is ultimately intended for...) but right now I am testing it on the actual server itself...


Report Offensive Follow Up For Removal

Response Number 3
Name: Larry21
Date: August 3, 2004 at 08:48:43 Pacific
Subject: Run file on server
Reply: (edit)

I forgot to add ?> at the end of the PHP code.


Report Offensive Follow Up For Removal

Response Number 4
Name: FBI Agent
Date: August 3, 2004 at 09:40:03 Pacific
Subject: Run file on server
Reply: (edit)

well i grabbed this php/mySQL book (PHP and MySQL - Web Development; ill give credit ;-) ) from the library about a week ago and have been reading it. it actually talks about this stuff in there.

its a bad idea to have a plain file (text file or whatever) that you are storing data to from the web.
first off, the if mulitple people access and record data to this file at the same time, the data will not be entered in correctly and will over-lap on top of each other.
second its very slow opening large files. have you ever tried opening a 2MB text file using notepad, it takes abnout 10 seconds (something like that) well when the web tries to access this text file, it will also take about 10 seconds.
ok, now the last part to this... the solution... a database. MySQL is much faster at storing and retrieving data than a flat file, it also can be accessed by mulitple people at the same time and not get all boggled up.
that is what the book suggest and i agree with it. im learning mySQL right now so i wont have to use any of these stupid files that are slow and possibly corruptable

FBI Agent

AIM: EliteAssassin187


Report Offensive Follow Up For Removal

Response Number 5
Name: Larry21
Date: August 3, 2004 at 22:34:54 Pacific
Subject: Run file on server
Reply: (edit)

Well truth is in the script above all that is needed is to run a file on the server- no input or output is neccessary. In addition, the file is tiny- maybe 10kB or something.

I guess that nobody has any ideas relating directly to the question?

I hope that at least Jaymc learned something here...

FBI- thanks for your effort at replying.


Report Offensive Follow Up For Removal


Response Number 6
Name: Jamie_McCoy
Date: August 5, 2004 at 01:32:11 Pacific
Subject: Run file on server
Reply: (edit)

yeh i did, especially in that java

i didnt know you could track key presses such as the up button

keydown==38

im guessing 38 represents the ascci code of the down character. with that said, i suppose you could do this for any button..

Jaymc.co.nr


Report Offensive Follow Up For Removal

Response Number 7
Name: Larry21
Date: August 5, 2004 at 22:47:41 Pacific
Subject: Run file on server
Reply: (edit)

Thats correct. The 'keyCode' function uses the key number and can then be used for other purposes. One thing though, Netscape uses other numbers completely (I think), so if you want your script to work with both Netscape and MSIE, you'll have to program both.

Here's a site that might help: http://cross-browser.com/x/examples/arrowkeys.html


Report Offensive Follow Up For Removal






Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Run file on server

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 4 Days.
Discuss in The Lounge