mIRC Home    About    Download    Register    News    Help

Print Thread
#10271 08/02/03 07:32 PM
Joined: Feb 2003
Posts: 9
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2003
Posts: 9
I'm currently working on creating a script that uses sockets to check a server to see if any updates are available. I know it's possible.. I just can't get it work properly. I'd like it to download/read a .txt file and play it to a @Custom Window. any help would be greatly appreciated.

#10272 09/02/03 06:37 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
The simplest way to do what you want is to put a version text file on your web site that just contains a line that has the version number (or build number) <space> URL link to the file, followed by a blank line. It's a simple matter to then open a socket to your web site, GET that file and compare the value found against the current version/build that's in use, stored inside your script somewhere, such as in a variable, in an .ini file or in a hash table entry.
Code:

on *:START: sockopen VersionCheck.YourScriptName www.mysite.com 80
on *:SOCKOPEN:VersionCheck.YourScriptName: sockwrite -n $sockname GET /path/to/MyVersion.txt
on *:SOCKREAD:VersionCheck.YourScriptName:{
  var %version
  sockread %version
  tokenize 32 %version
  if ($1 &gt; %Version.MyScript) echo 4 -ati2 * A newer version exists. Download it at $2
  sockclose $sockname
}

MyVersion.txt
12345 http[/b]://www[/b].mysite.com/downloads/MyScript-12345.zip
<blank line>

You can modify this script/idea to load into your custom window. cool


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#10273 10/02/03 04:39 AM
Joined: Feb 2003
Posts: 9
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2003
Posts: 9
The code works all but the $2 .. for the link to download the file. It echo's HTML instead of the link to the .zip file. Is it because of the host I'm using? or wha? Thank you for your help.

#10274 13/02/03 11:27 PM
Joined: Dec 2002
Posts: 1,527
_
Hoopy frood
Offline
Hoopy frood
_
Joined: Dec 2002
Posts: 1,527
hey hammer ive noticed that when i set this updater up as uve got it described here it actually doesnt read the file??? its giving me a header tag of a file .... heres how i set mine up and i testing to echo $1- and this this what ive got

on *:START: sockopen VersionCheck.D3m0nicChaos www.mysite.com 80
on *:SOCKOPEN:VersionCheck.D3m0nicChaos: sockwrite -n $sockname GET /httpdocs/downloads/D3m0nicChaos.txt
on *:SOCKREAD:VersionCheck.D3m0nicChaos:{
var %version.update
sockread %version.update
tokenize 32 %version.update
if ($1 > %Version.D3m0nicChaos) {
echo 13 -ati2 **** A 4NEWER version exists. Download it at8 $2 ****
echo 13 -ati2 **** If you do not download from $2 4NOW you will no longer have a current script ****
}
sockclose $sockname
}
now changing one of the lines to echo 13 -ati2 * $1-

produces this result .....

[18:25:58] * <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">

i know the file is there i just cant figure out why it isnt getting the lines from it ...... ive copied ur example here almost exactly but with no luck ..... im way new to messing or even attempting sockets so i would appreciate some pointers


D3m0nnet.com
#10275 14/02/03 03:59 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Both of you have HTML in your target file. You will notice, I hope, that my file does not have any formatting code as it is never meant to be viewed in anyone's browser, there is no link to it from any page, etc. It MUST have a blank line below it in order to read properly as I have laid out the script. It MUST NOT have any HTML tags in it. If you have a <!DOCTYPE declaration or an <HTML> tag, then you have formatted the file as .html.

MyVersion.txt
12345 http[/b]://www[/b].mysite.com/downloads/MyScript-12345.zip
<blank line>
<end of file>

Notice the complete lack of formatting.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#10276 14/02/03 06:10 PM
Joined: Dec 2002
Posts: 1,527
_
Hoopy frood
Offline
Hoopy frood
_
Joined: Dec 2002
Posts: 1,527
ok ive read and reread everything and i still cannot find anything wrong with it at all ..... the file is a .txt file and its path is http://www.mysite.com/downloads/D3m0nicChaos.txt

now when i type that into my browser (with switching the correct domainname) it only returns exactly what ive posted to u in the previous post ....... ok ..... ive opened the file thru my pc and it has no html in it at all ..... i created it thru notepad ...... it only reads exactly as u have stated with only minor changes to include my correct urls and version

now ive played a bit and tried changing the path to and when it doesnt find it mirc gives me a not connected error thru the socket ....... as im still very new with this i hope im explaining it all so that someone could give me a lil helping hand on it


D3m0nnet.com
#10277 14/02/03 09:26 PM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
What is the exact http address you're trying to reach? If we knew that, perhaps someone here could help you find it. Post exactly what you type into your browser, please, to reach that file. (It's obviously not going to be www.[/b]mysite.com.)


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#10278 14/02/03 09:42 PM
Joined: Dec 2002
Posts: 1,527
_
Hoopy frood
Offline
Hoopy frood
_
Joined: Dec 2002
Posts: 1,527


D3m0nnet.com
#10279 14/02/03 11:15 PM
Joined: Dec 2002
Posts: 1,527
_
Hoopy frood
Offline
Hoopy frood
_
Joined: Dec 2002
Posts: 1,527
ok i got it to work and i took alil code from one socket help request and combined it with this one ........ ive also changed the format of that .txt file to read similar to a .html page header ..... its the only way the file would show up as being found ...... anyway if ur interested heres what i came up with ....... i posted this link since its way too long to post here

check the script HERE

any input would be greatly appreciated as i dont know how to look for holes in that socket script cause im only begining to learn this stuff ty in advance


D3m0nnet.com
#10280 15/02/03 05:12 AM
Joined: Feb 2003
Posts: 9
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2003
Posts: 9
.. I'm not using any HTML in my file. Using the sockets i connect to www.PointBlankHosting.com and get /boredom/update.txt. Doing so I still recieve <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">. I've messed with everything I know how.. which isn't much and still cant' seem to get this to work. ..

#10281 15/02/03 07:36 AM
Joined: Dec 2002
Posts: 1,321
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
Code:

alias pbh sockopen pbhUpdate www.pointblankhosting.com 80
on *:SOCKOPEN:pbhUpdate:{
  sockwrite -n $sockname GET /boredom/update.txt HTTP/1.1
  sockwrite -n $sockname Host: www.pointblankhosting.com
  sockwrite -n $sockname Accept: text/plain
  sockwrite -n $sockname Pragma: no-cache
  sockwrite $sockname $crlf
  set -u300 %pbhUpdate.Body $false
}
on *:SOCKREAD:pbhUpdate:{
  if ($sockerr) {
    echo $color(ctcp) @pbhUpdate Error: $sock($sockname).wserr - $sock($sockname).wsmsg
    return
  }
  var %text
  while (1) {
    sockread %text
    if (!$sockbr) return
    if (!%text) set -u300 %pbhUpdate.Body $true
    if (%pbhUpdate.Body) &amp;&amp; (%text) {
      set %Script.Current.Version $gettok(%text, 1, 32)
      set %Script.Current.URL $gettok(%text, 2, 32)
 
      linesep -s
      echo $color(info2) -sbfirt * Current Version: %Script.Current.Version
      echo $color(info2) -sbfirt * Script URL: %Script.Current.URL
      linesep -s
 
      sockclose $sockname
      unset %pbhUpdate.Body
      halt
    }
  }
}

After this script runs, your current script version (as described in that file) will be contained in the variable %Script.Current.Version and the URL from which is available will be contained in the variable %Script.Current.URL.


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
#10282 15/02/03 03:51 PM
Joined: Feb 2003
Posts: 9
M
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
M
Joined: Feb 2003
Posts: 9
It works flawlessly. Thanks for the help!


Link Copied to Clipboard