Help - Search - Members - Calendar
Full Version: Vmware Executing A Php Script
Boostcruising.com > Computers and Technology > Tech Head Corner
n_one
The deal is, I have a PHP sms gateway script that when I run the script it will send me an sms, and depending on the url variables it will send me a specific message. The script sits on an apache webserver.

I need to have this run as a VMWare alarm in VIC(which runs on a management server which is win xp). At the moment I am doing it very dodgy and having it run this script:

c:\windows\system32\cmd.exe /c c:\alarm.bat "xxx Server is offline"

Then in that bat file it's something like:

iexplore http://path.to/php/sms/script.php?msg=%

Now it kind of works, but I know there must be a better way of doing this, currently after the script runs 3 or 4 times, it stops working.

Does anyone have any ideas as to how to remotely execute a php script on a webserver from a windows application.

Any help is much appreciated,
Cheers.
MarcD
Hrm.. How about using something like this? I dont code VB, so I dont know if it will work reliably.

Make a sendMessage.vbs


In it, stick this:

dim message
message = WScript.Arguments(0)

dim strURL
strURL = "http://path.to/php/sms/script.php?msg=" & message

Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5.1")
objWinHttp.Open "GET", strURL
objWinHttp.Send


Depending the version of windows you are using, you may need to use the WinHttp.WinHttpRequest.5 object.

Then all you would need to do is from the command line type wscript sendMessage.vbs "Hello World" (quotes are important!)
n_one
Thanks mate, I'll give it a go over the weekend and run some tests and see if I can get it working..

I've also been told I might be able to get a solution with wget, but I'll try this one out first.
MarcD
QUOTE (n_one @ Nov 7 2009, 03:21 PM) *
Thanks mate, I'll give it a go over the weekend and run some tests and see if I can get it working..

I've also been told I might be able to get a solution with wget, but I'll try this one out first.


It's funny you mentioned that because I started typing a reply that involved downloading wget and getting it installed under windows but it just clicked to me that you can run VBScript from the command line and you don't need to install anything extra to use it (I think). I'm a Java/C# programmer by trade so my knowledge of VB is almost non-existent. I just googled till I found some info about making HTTP requests using VBScript.

n_one
Ended up using cURL to execute the script, which works great. Used cURL for the extra functionality that it has, which has enabled me to do some other funky stuff as well.

Although when script executes in VIC it's still not working, the logs say that it's timing out. I've done some research and it looks like the VIC services need to run as an a specific user and not under the system account, as the system account won't let the scripts be executed(?). So I guess I'll keep playing with it and see if I can get a resolution.
MarcD
QUOTE (n_one @ Nov 13 2009, 08:34 PM) *
Ended up using cURL to execute the script, which works great. Used cURL for the extra functionality that it has, which has enabled me to do some other funky stuff as well.

Although when script executes in VIC it's still not working, the logs say that it's timing out. I've done some research and it looks like the VIC services need to run as an a specific user and not under the system account, as the system account won't let the scripts be executed(?). So I guess I'll keep playing with it and see if I can get a resolution.


What is VIC and is it running as a windows service? If so, you can just change the user that the service executes as fairly easily to get around that.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.