Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

can this be done in ASP?

Options
  • 17-08-2001 3:47pm
    #1
    Registered Users Posts: 12,309 ✭✭✭✭


    Web server A has a web site hosted on it with a particular text file and is running Unix/Apache (I believe).

    Web server B has a web site hosted on it and is running IIS 4.

    I want to create an ASP page on the web site on web server B that can retrieve said text file that text file from web server A and then do stuff to it.

    The question is IF this can be done in ASP without installing any server components... and if so, HOW?

    Bard
    'First motorbike in the bible ???? ---- a Triumph --- 'Yea verily Moses struck down the ammmanites and all the land heard the roar of his triumph !!!'


Comments

  • Registered Users Posts: 861 ✭✭✭Slosh


    Sure... at the end of the day you're still opening a text file, albeit on a different server.

    Take a gander at the filesystem object.

    S.


  • Registered Users Posts: 1,842 ✭✭✭phaxx


    So far I've had no experience whatsoever with ASP, but anyhow...

    Create a connection to webserver A, mimic a browser's request for that file. Below are the headers you'll need to send:
    GET /path/to/file.txt HTTP/1.0
    Host: remote.webserver.name
    Accept: text/html, text/plain, text/sgml, */*;q=0.01
    Accept-Encoding: gzip, compress
    Accept-Language: en
    Pragma: no-cache
    Cache-Control: no-cache
    User-Agent: hello
    Referer: (stick the address of your asp script here - not required, but it's a good idea)
    

    When you do that, read from the socket and you should get something similar to this:
    HTTP/1.1 200 OK
    Date: Thu, 19 Jul 2001 14:19:06 GMT
    Server: Apache/1.3.9 (Unix) PHP/4.0.4pl1
    X-Powered-By: PHP/4.0.4pl1
    Connection: close
    Content-Type: text/html
    
    <html>
    ...etc
    

    Note that to signal the end of the headers, send a blank line, and then the webserver goes to work and gives you the file. [edit]same rule applies to the server's headers and data for you. stupid code tag in ubbcode ignores blank lines.[/edit]

    Of course, in PHP, you can just do $data = file("http://url.com/file.txt"); and it does all of the above...
    file() is used to access local files too.
    I believe there is a win32 port of php, you might want to check that out, or, alternatively, use a real operating system to host the site. :P



    [This message has been edited by phaxx (edited 22-08-2001).]


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    <font face="Verdana, Arial" size="2">Originally posted by Slosh:
    Sure... at the end of the day you're still opening a text file, albeit on a different server.

    Take a gander at the filesystem object.
    </font>

    Don't be silly. It's accessing the document remotely by requesting it from a server not the other machines filesystem. PHP just gives that impression because it uses the same command.

    The old down and dirty method of doing this on IIS was to instansiate the Inet dll (many 3rd party components such as ASPTear actually just did this):
    Set Inet = Server.CreateObject("InetCtls.Inet.1")
    Inet.RequestTimeOut=20
    Inet.Url = "http://www.boards.ie/"
    sResponse = Inet.OpenURL
    Response.Write(sResponse)
    Set Inet = Nothing
    

    Most IIS servers will have the XMLHTTP componant installed, which I think IIS 5 is shipped with:
    Set objHttp = CreateObject("Microsoft.XMLHTTP")
    objHttp.open "GET", "http://www.boards.ie/", False, "", ""
    objHttp.setRequestHeader "foo","bar"
    objHttp.send
    sResponse = objHttp.responseText
    Response.Write(sResponse)
    Set objHttp = Nothing
    

    It's a lot more powerful and stable than using the Inet dll, so I'd try that first. Hope this helps.



    "Just because I'm evil doesn't mean I'm not nice." - Charlie Fulton


  • Closed Accounts Posts: 79 ✭✭Alis


    In my experience the Inet dll is just plain flakey when used in the method you suggest.

    ASP Tear or XMLHTTP should do the trick but I think the "IIS 4 & no server components" requirements would rule that out.

    I'm thinking their must be something you could use, but if there is it is not coming to mind, I've always used components for this kind thing.

    I don't suppose you have access to that Unix/Apache box. It might be easier to set up a system there which allows the file to be called from any page via a JavaScript include. If you do, say, and I'll explain how you do that, it is very easy smile.gif

    Other than that I've seen some inventive techniques used by content grabbing ASP developers who have sites on webservers that they can't add .dlls to.

    Check out this:
    http://coveryourasp.com/GetNews.asp


  • Registered Users Posts: 12,309 ✭✭✭✭Bard


    <font face="Verdana, Arial" size="2">
    Set Inet = Server.CreateObject("InetCtls.Inet.1")
    Inet.RequestTimeOut=20
    Inet.Url = "http://www.boards.ie/&quot;
    sResponse = Inet.OpenURL
    Response.Write(sResponse)
    Set Inet = Nothing
    </font>

    gives this...:
    <font face="Verdana, Arial" size="2">
    Server object error 'ASP 0177 : 80040112'

    Server.CreateObject Failed

    /test.asp, line 2

    80040112
    </font>

    XMLHTTP and ASP Tear, etc. are not an option. It's IIS4, has XML Parser 2.5 (I think... I know it's not v.3 anyway) and I can't install additional components. Neither can I install PHP. I'm not going to get into the argument about "using a real operating system to host the site" - it's NT4 with IIS4 - that IS a real operating system, and it's the system I know and have to use.

    Bard
    'First motorbike in the bible ???? ---- a Triumph --- 'Yea verily Moses struck down the ammmanites and all the land heard the roar of his triumph !!!'


  • Advertisement
  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    <font face="Verdana, Arial" size="2">Originally posted by Alis:
    In my experience the Inet dll is just plain flakey when used in the method you suggest.

    ASP Tear or XMLHTTP should do the trick
    </font>

    FYI, ASP Tear actually just uses the Inet dll. Moot point, I know.

    btw, are you following me around Alis? tongue.gif
    <font face="Verdana, Arial" size="2">Originally posted by Bard:
    Server.CreateObject Failed </font>
    On IIS? Very Odd - should be there. Might be registered with a different creation string. Do a search of MSDN to see if there are any variants to this.

    Another thing you can try is using the old IE5 XMLDOM for this purpose. The creation string is "microsoft.xmldom" and it gets a url using the a Load method, if I remember correctly.


    "Just because I'm evil doesn't mean I'm not nice." - Charlie Fulton


Advertisement