Jump to content

Recommended Posts

Posted

I successfully configured a cron job in cpanel to run a php script. Now I would like to run that script remotely from VBScript.

 

Dim Controller, RemoteScript

Set Controller = WScript.CreateObject("WSHController")

Set RemoteScript = Controller.CreateScript("http://www.MyWebSite.com/MyPath/MyScript.php")

RemoteScript.Execute

 

I have placed '#!/usr/bin/php' in the script.

 

Can anyone tell me why this doesn't work?

 

Thanks

Posted

Welcome to the forums, jackaroo! ;)

 

From what I can tell by reading the WSH documentation, the methods you're using in your script do not support running a script via a URL, nor do they support remote execution of scripts on a non-Windows server.

 

To run a script on your account by merely performing an HTTP 'GET' request on its URL, I believe the following script would do what you want:

>Dim url	'URL to retrieve
Dim sHTML  'String to hold HTML sent by server

url = "http://www.MyWebSite.com/MyPath/MyScript.php"
sHTML = HTTPGet(url)

Function HTTPGet(strURL)
Dim strReturn
Dim objHTTP
If Len(strURL) Then
	Set objHTTP = WScript.CreateObject("Microsoft.XMLHTTP")
	objHTTP.open "GET", strURL, False
	objHTTP.send
	strReturn = objHTTP.responseText
End If
HTTPGet = strReturn   
End Function

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...