Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Learning but need help running programs 1

Status
Not open for further replies.

timgerr

IS-IT--Management
Joined
Jan 22, 2004
Messages
364
Location
US
Hello all, I am new to php and need have created a php page that will collect information from a user then use that information to run a batch file. I am having troubles with the exec() command, it is not doing what I want it to do. I need to start a program on the computer not just the service. Here is an example.
When I use:
Run.php
<?
$command = "d:\test.bat";
exec($command);
?>

The batch file starts a vb script that starts a HyperTerminal session and then sends keys to the program. When I run the run.php script I see that HyperTerminal has started in the task manager but I need to have it started on the desktop. If I run the test.bat on the desktop everything works fine. I need hypertrm.exe to start on the screen to send oShell.SendKeys to the program

If I use the same script
<?
$command = "c:\windows\notepad.exe";
exec($command);
?>
I notice that notepad was started in the taskmanager put not on my screen. I was wondering what command I should use to get notepad to start on my computer when I go to I am using notepad as an example because if I can get that to work then I should get the hypertrm.exe to work.

Thanks
 
you're actually running the script like a client. and your command opens the file you need (e.g. notepad.exe) on the server (which in your case is the same computer as the client) that's why it starts in the 'background'.

anyway, you will not be able to open programs on the client computer using PHP if that's your final goal.

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
I agree with DaZZled. You can't invoke programs on the client's machine - after all you don't even know for sure what kind of OS they run. Could by anything, like *NIX to OS/2.

Maybe you can post a question about what you want to do and we could advise you on an alternate solution.
 
You can't run GUI applications on a Win32 machine from a web server. As you have seen, there is no desktop available for the applications to interact with.

In a lot of cases, you can use PHP builtin functionality to do what you need, particularly if the thing you need to do is something not specific to a particular OS. PHP has, for example, socket programming available for interaction with a foreign machines and filesystem functions to manipulate text files, so invocation of hyperterminal or notepad is unnecessary and contraindicated.

If you need to perform some OS-specific function on the server, you will find after a little research that there are command-line applications available which can duplicate much of the functionality of Win32's GUI applications.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I am sorry, I might have to give you more information, I want the script to run on the server, not the client. I want notepad to open on the server.

Thanks
 
timgerr:
Did you read my post about GUI applications invoked by scripts on the web server not having a desktop to interact with?


I'll bet good money right now that you don't need Notepad and that you can do whatever you need to do using PHP's builtin functions.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
If I wanted to start a hypertrm session after gathering up information from a webpage, can I execute the session from a PHP CLI?

Timgerr
 
What were you going to do with Hyperterminal? If you're going to use it to telnet to another machine, you can do that using PHP's builtin socket programming.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I have created a PHP web page on a W32 box that grabs user information that is inputed into the web page. The PHP web page then creates a vb script to open HyperTerminal, connect to come 3 and place a call. The vb script is sending keys to HyperTerminal to enter information to a voice automated prompt. This takes about 10 minutes in all. I want to have the W32box that is running apache run this vb script when the user hits submit.

By the way, thanks for all ur help, I am starting to dig PHP.
Timgerr
 
Sorry, that is com 3, the come port that the modem sits on.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top