Jump to content

Scripting and PHP


kudrow
 Share

Recommended Posts

Hello,

I have a little issue executing a script with PHP. It seams PHP is waiting for a response from the script it is executing. My question is how do I send the output from the script to the php window? For instance, when I run the php command exec ('dir'), I get the directoy info back into the php window within internet explorer. The only way I can see to ouput info with AutoIT is to a MsgBox. Any suggestions?

Thanks!

Link to comment
Share on other sites

Hi,

If I understand you correctly, you want to read the output of the php script?

Why don't you get the source code like any other page? (_INetGetSource)

Use the command echo in php to do it.

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

Hi,

If I understand you correctly, you want to read the output of the php script?

Why don't you get the source code like any other page? (_INetGetSource)

Use the command echo in php to do it.

Br, FireFox.

Not exactly. Lets say I run a php script and tell it to execute example.exe; the page hangs and times out because it is waiting for a response from example.exe. Lets say example.exe is just a little script that gets the external IP address from whatsmyip.org. It outputs the IP address in a MsgBox. Obviously PHP can not read from the MsgBox created by the script. I have been experimenting with ConsoleWrite but if I build the script with the console option checked, the script will not run. I hope I am making more sense.

Thanks.

Link to comment
Share on other sites

OK, I am getting a little closer. No matter what script I execute with PHP, it never executes correctly. PHP is not hanging, the script is. If I have task manager up and run my php, php executes my script and the script becomes visiable in task manager. At that point, the php is waiting for the script to finish executing so it appears to hang. If I manually kill the script in task manager the php will finish and return the errors from the script. I am thinking this may be a permissions issue but not sure. I am attaching my script file. This script is just for testing the php execution. Below is the error I get in php when I kill the script in task manager.

--> IE.au3 V2.4-0 Error from function _IECreate (Browser Object Creation Failed) --> IE.au3 V2.4-0 Error from function _IEBodyReadText, $_IEStatus_InvalidDataType

#include 

Local $oIE = _IECreate("www.whatsmyip.us/",0,0)
Local $sText = _IEBodyReadText($oIE)

Local $search = StringRegExp($sText, '([0-9]{1,3})',3)
Global $p="."
Local $ip1=$search[0]
Local $ip2=$search[1]
Local $ip3=$search[2]
Local $ip4=$search[3]
local $ip=$ip1 & $p & $ip2 & $p & $ip3 & $p & $ip4

;MsgBox (1, "Result", $ip)

ConsoleWrite ( $ip )

Exit

Any help would be greatly appreciated.

Link to comment
Share on other sites

so you need to get your own IP adress and display it to user?

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

I can't test the IE part because I have not it installed on my computer, so here you go :

<?php
exec('ipcheck2.exe', $aOutPut);

print_r($aOutPut);
?>

#include <INet.au3>

Global $sText = _INetGetSource("http://www.whatsmyip.us/")

Global $search = StringRegExp($sText, '([0-9]{1,3})', 3)
Global $p = "."

Local $ip1 = $search[0]
Local $ip2 = $search[1]
Local $ip3 = $search[2]
Local $ip4 = $search[3]
Local $ip = $ip1 & $p & $ip2 & $p & $ip3 & $p & $ip4

ConsoleWrite($ip)

Exit

Br, FireFox.

Edited by FireFox
Link to comment
Share on other sites

so you need to get your own IP adress and display it to user?

Ignore what the script actually does, its just an example. The goal I am trying to achieve is to execute "ANY" application using PHP. I can get normal cmds to execute fine but when I try to execute anything like notepad.exe or my own .exe file, the exe hangs and never executes. I think it may have something to do with user/permissions. I can check the details of the app in task manager and it shows it being ran as IUSR instead of the local user account.

FireFox, your php returns the same results. I greatly appreciate all of your help with this. I am going to continue to research possible permissions issues. Feel free to recommend something else.

Thanks!

Link to comment
Share on other sites

to me on xp spcipt i get Array ( [0] => xxx.xxx.xxx.xxx )in ie user page, so its ok

are you shure you compiled his autoit code? cos your and his code are diffrent

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

to me on xp spcipt i get Array ( [0] => xxx.xxx.xxx.xxx )in ie user page, so its ok

are you shure you compiled his autoit code? cos your and his code are diffrent

Are you executing the script from IE using php?

The script runs fine locally. I can double click the compiled exe and it runs with no issues.

Edited by kudrow
Link to comment
Share on other sites

yes i am executing the script from IE using php

im using wamp server, i compiled script from FireFoxes post and put it next to index.php in my main www folder, and on adress (i call adress from my ie) http://localhost/ (when wamp is started up) i do get ip adress from autoit console displayed on http://localhost/ page in ie, in the next format

Array ( [0] => xxx.xxx.xxx.xxx )

so no i dont start autoit with double click

php starts autoit, php grabs output from it, php displayes data on my ie

i hope you don't play on linux server

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

yes i am executing the script from IE using php

im using wamp server, i compiled script from FireFoxes post and put it next to index.php in my main www folder, and on adress (i call adress from my ie) http://localhost/ (when wamp is started up) i do get ip adress from autoit console displayed on http://localhost/ page in ie, in the next format

Array ( [0] => xxx.xxx.xxx.xxx )

so no i dont start autoit with double click

php starts autoit, php grabs output from it, php displayes data on my ie

i hope you don't play on linux server

No, no linux for me. I am using IIS. I am going to switch over to wamp and give it a shot. Thanks!
Link to comment
Share on other sites

OK so I removed IIS and loaded wamp. I did get good results running the autoit script designed to return info back to php. So now I want to execute another type of application like for example sake, notepad. The application gets executed but nothing shows up. Any thoughts?

Link to comment
Share on other sites

PROBLEM SOLVED!!! I found this post here.

So, if you want to use Apache/PHP as a proxy for launching GUI apps, you'll need to run Apache as a console application.

First, if Apache is already installed as a service, you'll need to set it's startup type to "manual" using the services snap-in. (%SystemRoot%system32services.msc) Search for Services in the start menu search box.

Then add a shortcut to C:apachebinhttpd.exe (or wherever Apache is installed) to your Startup folder, and set that shortcut to start minimized. You can use an app like TrayIt! to force Apache down into the system tray.

Then use any of the methods outlined on the PHP website and you will be able to open a Windows application from PHP and see it's GUI.

Link to comment
Share on other sites

yes, ask on php forum for gods sake :0)

http://php.net/manual/en/book.exec.php

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

  • 7 years later...
On 10/11/2012 at 3:27 PM, kudrow said:

PROBLEM SOLVED!!! I found this post here.

 

So, if you want to use Apache/PHP as a proxy for launching GUI apps, you'll need to run Apache as a console application.

 

First, if Apache is already installed as a service, you'll need to set it's startup type to "manual" using the services snap-in. (%SystemRoot%system32services.msc) Search for Services in the start menu search box.

 

Then add a shortcut to C:apachebinhttpd.exe (or wherever Apache is installed) to your Startup folder, and set that shortcut to start minimized. You can use an app like TrayIt! to force Apache down into the system tray.

 

Then use any of the methods outlined on the PHP website and you will be able to open a Windows application from PHP and see it's GUI.

Just registered to say this was exactly my problem!

Running httpd.exe manually allows me to run AutoIt with GUIs. ;)

Thank you!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...