SPONSORS:






User Tag List

Results 1 to 6 of 6
  1. #1
    Junior Member
    Join Date
    Sep 2000
    Location
    Beaverton, OR USA
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using Wininet.dll in a Silktest script

    Hi everyone,

    So I'm trying to get Wininet functions working in Silk. Basically I'm leveraging off of the link checker that was written in one of the Segue Newsletters.

    I can successfully use simple functions to establish an internet connection, and then open up a connection with an FTP server. I do this with:
    hConn = InternetOpenA(sUserAgent, 1, null, null, 0)

    and then:
    internetconnect = InternetConnectA(hConn, "<hostname>", 0, "<username>", "<password>", 2, 0, 0)

    (Please excuse the roughness of the above coding...this is nothing more than a hack right now. Obviously I have removed the hostname, username, and password).

    Once I get connected to the FTP site, I should be able to use any of the established FTP functions in the Wininet library. I can't get ANY of *those* functions to work, however. Like if I try and use the FtpGetFile function with:
    getfile = FtpGetFileA(hConn, "/opt/cscc/log/time.3084.out", "c:\\time.out", 0, 0, 0, 0)

    "getfile" ends up being FALSE, because the function fails. I try and same thing with FtpGetCurrentDirectory, FtpSetCurrentDirectory, etc...none of them work.

    Has anybody had any success in implimenting some FTP functions in the Wininet library? Thanks a bunch for your help.

    Oh, I wanted to add, I was extremely impressed with how Silk uses these functions, especially in the link checker example from the Segue Newsletter. I'd be very interested to hear how other people have implimented this in their scripts, not just FTP related.


    Andrew



    [This message has been edited by Erich Zann (edited 11-29-2000).]

  2. #2
    Junior Member
    Join Date
    Sep 2000
    Location
    Beaverton, OR USA
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Using Wininet.dll in a Silktest script

    Well this is strange, I've never actually had a whole thread with myself before... :-)

    So the saga continues. I leveraged a 'dll' from a developer to start calling his functions directly rather than going through the user interface. Unfortunately, these are not standard dll functions, they are COM Objects.

    Has anyone had success calling COM objects from Silk?? Thanks!!

    Andrew

  3. #3
    Junior Member
    Join Date
    Sep 2000
    Location
    Beaverton, OR USA
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Using Wininet.dll in a Silktest script

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Erich Zann:
    Has anyone had success calling COM objects from Silk??<HR></BLOCKQUOTE>

    Of coarse not, because Silk doesn't support COM objects.

    After perusing the back messages on this board, I see this has been discussed before. :-)

    Andrew

  4. #4
    Junior Member
    Join Date
    Sep 2000
    Location
    Beaverton, OR USA
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Using Wininet.dll in a Silktest script

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Erich Zann:
    Has anybody had any success in implimenting some FTP functions in the Wininet library? Thanks a bunch for your help.<HR></BLOCKQUOTE>

    Hi everyone,

    After some research, I found the solution to my above problem, so I thought I'd share it with you all.

    Turns out the FTP server we are using requires an SSH login. I'm not too familiar with this, but what it means is that by using SSH you can set up a proxy between the client and the server. Aparently the normal TCP/IP login is a direct connect.

    ANYHOW, this is a Silktest board, so let me get to the point. The WinInet FTP functions won't work if you have to go through a proxy, because proxy's only (typically) allow an HTTP connection. Please excuse my lack of technical knowledge here...I'm probably getting the details wrong. At any rate, that's why the functions weren't working. They can't connect up with the server properly.

    There is a way to get around this though, and I have implimented it into a Silktest script. Granted, you don't have the functionality that the FTP functions give you, but you do have the InternetReadFile command, which reads in a URL that you specify. By making the URL an "ftp://...." address to a file on my server, Silk can connect to it.

    In case anybody is interested, the SilkTest script I have developed logs into an FTP server (password protected, but by using a URL instead of a direct port 21 FTP connection), retrieves a file 255 bytes at a time and searches for a keyword. Once that keyword is found it could do anything (fire off another function, record to a log file, etc...). If the keyword is never found, it reports so.

    And by using the Wininet functions, I don't have to use Silk to navigate through a browser or any of that hassle, no lag times in waiting for pages to load, etc... This is done directly through an internet connection made through the network, so the execution (for Silk standards) is lightening fast.

    Anyhow, just thought I'd share. Still interested if anybody else has done this sort of thing... :-)

    Andrew

  5. #5
    Senior Member
    Join Date
    Mar 2000
    Location
    pisctaway, NJ USA
    Posts
    188
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Using Wininet.dll in a Silktest script

    I realize this was on Segue's Newsletter some time ago, but can you post or EMAIL the code to grap a file either via http or FTP using winnit.dll?
    Tony
    ponte2@bigfoot.com

  6. #6
    Junior Member
    Join Date
    Sep 2000
    Location
    Beaverton, OR USA
    Posts
    27
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Using Wininet.dll in a Silktest script

    Sure thing. I'll actually post code out of my own application of the wininet.dll file because it's easier and simpler than the web spider on the Segue site.

    Sorry, everyone, that the formatting is screwed here...my code must have messed up the length of the lines.

    The first to do in order to use a dll is to declare it and it's function prototypes like so:

    Now that you have the functions declared, you can go ahead and use them in your SilkTest script. For instance, the first thing you must do in order to perform internet functions is declare a connection like this:

    (obviously I have declared certain variables elsewhere in the script to use as parameters for the function InternetOpenA())

    Once that has been done, any of the internet-related functions in the Wininet.dll file can be performed, given the right system requirements. For example, if you want to connect to an FTP server (without SSH, of coarse, see above message) then there are numerous FTP functions at your desposal. If you want to manipulate URL's, there are functions for that too.

    Retrieving a file from an FTP server can be done in two ways. One, you can use the FTP functions that do that, if you can connect to your FTP server without going through a proxy. If you must go through a proxy, however, then you must use the Internet functions, which are more limited in terms of file manipulation, but will still retrieve a file just the same. Here's some code to do that:

    Basically what this code does is first, open a URL handle called hFile. I then use the Silk function ResOpenList in order to create a tree into which I will dump the contents of the file to be retrieved. Then enters the if statement. Because the handle, upon success, will be an integer greater than zero, IF the establishment of the handle is true, then enter into a while loop to read the contents of the file.

    The while loop works like this: It calls the InternetReadFile function which reads the location defined in the InternetOpenUrl function (sUrl). iMaxLength is the maximum length of characters to read at a time. I turned this into a search engine by doing this: grab 255 bytes of data, search for a string. If not found, grab the next 255, etc... This will create search results which are accurate to the nearest 255 bytes. The lower the iMaxLength, the longer it will take to execute.

    sData is the variable which contains the newly read data. sOutput is the holder, and sData is just appended to sOutput the whole loop. At the end, sOutput is the var which will contain the entire file. I then have it dump into the results file via a Print statement.

    Make sure to close the connections to both the Url and the Internet connection made earlier, by using the InternetCloseHandle(hFile) (or whatever h* your handle is called).

    The applications for using Wininet.dll are limitless. I have created a search engine (based on the web spider thing from Segue), a parser for log files on our internal server, and a diff utility for web site's (it traverses through a web site, like the spider, and actually records the HTML for each page. On a small web site, this is but a minor task. Next time we get a build, I run it against the "masters" in place and the diff utility tells me which HTML pages have been modified so I know where to concentrate my testing).

    Good luck with this. It's a powerful aspect of Silk, one which I have found incredibly useful and effecient.

    Erich

    [This message has been edited by Erich Zann (edited 12-04-2000).]

    [This message has been edited by Erich Zann (edited 12-04-2000).]

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 03:49 PM.

Copyright BetaSoft Inc.