Jump to content

Getting Mad with InetGet


Recommended Posts

Hi!

I really get mad with the InetGet function. My program should check if there is a dedicated file online on a webserver. So:

$online = InetGet("url")

if $online = 1 then
msgbox(0, "Onlinestatus:", "Online")
else
msgbox(0, "Onlinestatus:", "Offline")
endif

Very simple program it seems, but it lies. I checked the URL with firefox and could see the textfile. Then I copied and pasted the URL in my script, and it says: Offline. But that is not true, the rights of the file are set to 777 and everyone can view it. Only my program cant.

Sorry, I do not know what to do :)

Link to comment
Share on other sites

I really get mad with the InetGet function.

You should resist that - bad for the stress levels... :D

My program should check if there is a dedicated file online on a webserver.

$online = InetGet("url")

if $online = 1 then
msgbox(0, "Onlinestatus:", "Online")
else
msgbox(0, "Onlinestatus:", "Offline")
endif
I don't think that is a valid use of InetGet(). Even though the help file shows the filename parameter as optional, that is only true in the special case of InetGet("Abort"). You need to specify a local file to save the data to.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hm, thanks :)

I did so, and the funny thing is, it can download a file which doesnt exist! Example:

$online = InetGet("http:foo.com/bar.txt", "online.txt")

Then it creates a textfile with some stuff in it.. And there begin the new problems. It downloads a file which does not exist :hate: ! It creates a textfile named online.txt. A part of the content:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>

<head>

<title>Seite

...

I compared the file downloaded with the sourcecode from the error 404 site: They are the same.

Maybe there is the problem? I think the program thinks that the error 404 site is a positive result. How can i prevent this?

And then it says: Yes filestatus Online. But that is not true, because I deleted the file from the webserver and noone is able to view it (just because it does not exist).

Please Im hopeless...

Edited by Term!nX
Link to comment
Share on other sites

What you are seeing make sense to me. In a regular browser, try to look at http://www.autoitscript.com/none_such.html. You DO get a page back; an error page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>AutoItScript Error</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<link href="css/default.css" rel="stylesheet" type="text/css">

<div id="container">
<body>
<p><img src="/images/autoit_6_240x100.jpg" width="240" height="100"></p>
<p><strong><em>&quot;404: The page/file you requested could not be found.&quot;</em></strong></p>
<p> Sorry! We can't find the file or page you asked for. If you came from an external site the links may be out of date.&nbsp; </p>

<p>Please try the <a href="/index.php">AutoItScript</a> home page, the <a href="/autoit3/">AutoIt
  v3</a> page or the <a href="/AutoIt/">AutoIt v2</a> home page to find your file.</p>
</body>
</div>
</html>

So you will have to look at the contents of online.txt to see if it is what you wanted, or an error page.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

If what you are downloading is not supposed to be a web page at all, that will work.

If what you wanted was a web page and you want to know if you got an error page instead you could check the <title> field.

$Output = "output.txt"
$sOutput = FileRead($Output, FileGetSize($Output))
If _StringBetween($sOutput, "<title>", "</title>") = "AutoItScript Error" Then MsgBox(16, "Error", "Got error.")

If you wind up very far down that path, you'll be better off to switch to IE.au3 functions instead of InetGet().

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Okay I understand, sounds logical either. But for my purposes your first solutions is good enough (but now I know what to do if the case is as complicated as you described).

I have got another problem:

I want to implent variables in the URL. Hard to explain, but the user inputs some variables.

$var1 = 1

$var2 = 2

$var3 = 3

;the url should be: http://foo.fo.host.de/web/123.txt, so:

$url = "http:// foo.fo.host.de/web/" & $var1 & $var2 & $var3 & ".txt"

;I showed the url with a msgbox and it was correctly: http::// foo.fo.host.de/web/123.txt , but the checkroutine gives an error. $url = "http:// foo.fo.host.de/web/123.txt" doesnt.

Is the expression _ $url = "http:// foo.fo.host.de/web/" & $var1 & $var2 & $var3 & ".txt" _ correct? In my eyes there is the mistake.

Edited by Term!nX
Link to comment
Share on other sites

I have got another problem:

I want to implent variables in the URL. Hard to explain, but the user inputs some variables.

$var1 = 1

$var2 = 2

$var3 = 3

;the url should be: http://foo.fo.host.de/web/123.txt, so:

$url = "http:// foo.fo.host.de/web/" & $var1 & $var2 & $var3 & ".txt"

;I showed the url with a msgbox and it was correctly: http::// foo.fo.host.de/web/123.txt , but the checkroutine gives an error. $url = "http:// foo.fo.host.de/web/123.txt" doesnt.

Is the expression _ $url = "http:// foo.fo.host.de/web/" & $var1 & $var2 & $var3 & ".txt" _ correct? In my eyes there is the mistake.

There is a space between "http://" and "foo." that probably doesn't belong... :)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...