curl from WSH/VBScript

Posted by: AndrewT

curl from WSH/VBScript - 04/05/2003 17:48

Has anyone here used curl from these languages? I'm looking for a jumpstart if anyone has any tips or sample code (especially with Libcurl).
Posted by: andy

Re: curl from WSH/VBScript - 05/05/2003 04:24

Unless someone has already written a wrapper for libcurl that exposes it via COM's IDispatch (and have made sure that the return arguments are in a form that the Microsoft Script Engine can handle) then you are out of luck. Googling doesn't provide any evidence that anyone has done this.

If all you wanted to do was make HTTP and HTTPS calls then an alternative is the MSXMLHTTP object that is part of the MSXML parser. While is is designed for making HTTP calls to fetch XML it can be used just as easily to get the contents of web pages.

Here is a quick example of getting the contents of a webpage.

(warning, untested code...)

Dim oXmlHttp
Dim sWebPage

set oXmlHttp = CreateObject("MSXML2.XMLHTTP")

oXmlHttp.open "GET", "http://www.norman.cx/", false
oXmlHttp.send ""
sWebPage = oXmlHttp.responseText
Posted by: AndrewT

Re: curl from WSH/VBScript - 05/05/2003 16:08

Thanks for the suggestion about the MSXML parser, I think I can make good use of that somewhere else in my app. quite soon. The task I had in mind for curl is reliable FTP Get/Put.

I had originally planned to use Ncftp for FTP but I've since discovered that the API variant costs $500 and appears to be *nix only. I guess* I can still use the command line versions of either curl or Ncftp by invoking a cmd shell from WSH but I was looking for something more elegant

* (I am assuming that I can run the WSH script from task scheduler AND have it shell cmd windows without a user logged on interactively. I will try to test that shortly).
Posted by: andy

Re: curl from WSH/VBScript - 05/05/2003 22:46

I am assuming that I can run the WSH script from task scheduler AND have it shell cmd windows without a user logged on interactively. I will try to test that shortly

As far as I am aware there is no way to run EXEs direct from VBScript (unless WSH provides a way). I have always had to write an VB ActiveX DLL that I called to run EXEs from script (very simple DLL to write as it tends to be a one-liner).