mIRC Home    About    Download    Register    News    Help

Print Thread
#40891 10/08/03 07:08 AM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
I would like to make my script auto update itself.
I was thinking of using zip files, but it seems that they got corrupted.

I'm using:
Code:
on *:sockopen:update: {
  if ($sockerr == 0 ) { 
    sockwrite -n $sockname GET update.zip HTTP/1.1 
    sockwrite -n $sockname Host: www.something.com $+ $str($crlf ,2)
    .timercloseupdate 1 180 sockclose update
  }
  else { sockclose update | halt }
}
on *:sockread:update: { 
  sockread %temp 
  write update.zip %temp
}



The file seems to get only so a size of 24KB, and it adds some information at the beggining of the file which corrupts on more.

Is there a way to get a text file or a zip file without it being corrupted?

#40892 10/08/03 09:30 AM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
First off, I'd kill that timer.

Second, read this


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#40893 10/08/03 10:47 AM
Joined: Jan 2003
Posts: 148
K
Vogon poet
Offline
Vogon poet
K
Joined: Jan 2003
Posts: 148
Use the /bwrite command instead..

Code:
on *:sockread:update: {  
 sockread &temp   
 bwrite update.zip -1 &temp
}
 

#40894 10/08/03 11:07 AM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
Why kill the timer?

I want the the socket will be closed when it is done, and I think that 3 minutes should be enough.

Opened sockets can cause problems like security etc.

Ok, I will try to use the bwrite.


//EDIT:
Never heard of the bwrite command, and I can't find anything about it in the mIRC help.

Last edited by saragani; 10/08/03 11:22 AM.
#40895 10/08/03 11:25 AM
Joined: Mar 2003
Posts: 1,271
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Mar 2003
Posts: 1,271
Considering the huge post Hammer did I doubt it's as simple as Knappen suggests. And you should kill the timer because the socket will close by itself when it's done. If you kill the socket after N seconds, who is gonna guarantee you you have received all the data within that time?


DALnet #Helpdesk
I hear and I forget. I see and I remember. I do and I understand. -Confucius
#40896 10/08/03 11:31 AM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
Ok. I will disbale the timer.

#40897 10/08/03 12:02 PM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
If I use HTTP/1.1 then I get the file but it looks like:

HTTP/1.1 200 OK
Date: Sun, 10 Aug 2003 10:58:06 GMT
Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) mod_jk/1.2.0 mod_perl/1.24_01 PHP/4.2.2 FrontPage/5.0.2 mod_ssl/2.8.12 OpenSSL/0.9.6b
Last-Modified: Sun, 10 Aug 2003 10:37:42 GMT
ETag: "c40a2-de9c-3f362076"
Accept-Ranges: bytes
Content-Length: 56988
Content-Type: application/zip

PK   ׃X.‘œד~ …ַ


The file works, but it adds junk to the start of the file (which I don't want). If I don't put the HTTP/1.1, then I don't get the file.


Last edited by saragani; 10/08/03 12:17 PM.
#40898 10/08/03 01:59 PM
Joined: Jan 2003
Posts: 148
K
Vogon poet
Offline
Vogon poet
K
Joined: Jan 2003
Posts: 148
I use /bwrite to dowload my update file! (/help /bwrite)

on *:sockopen:download:{
sockwrite -n $sockname GET /knappen/ $+ %version $+ .exe
}

on *:sockread:download:{
sockread &temp
if (!$sockbr) return
bwrite %version $+ .exe -1 &temp
}

And don`t use HTTP/1.1 when u r downloading..
Only sockwrite -n $sockname GET update.zip

#40899 10/08/03 02:29 PM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
But why if I don't use the HTTP/1.1 I get nothing, or I get 404, file not found?


#40900 10/08/03 05:15 PM
Joined: Jan 2003
Posts: 148
K
Vogon poet
Offline
Vogon poet
K
Joined: Jan 2003
Posts: 148
post your entire code then so Ii can see it and perhaps correct it...

#40901 11/08/03 04:29 AM
Joined: Dec 2002
Posts: 5
M
Nutrimatic drinks dispenser
Offline
Nutrimatic drinks dispenser
M
Joined: Dec 2002
Posts: 5
I wrote this snippet just now, i made it to handle multiple downloads at once.

Usage: /download www.somewhere.com/dir/file.zip

Example 1: /download http://maffew2.tripod.com/temp/gameover.wav
Example 2: /download http://www23.brinkster.com/maffew007/spanky.rar
Example 3: /download maffew2.tripod.com/carl.jpg

Code:
alias -l " { return $+(",$$1-,") }
alias download {
  :start
  var %sock = download. $+ $ticks,%address,%file
  if ($sock(%sock)) { goto start }
  if (!$1) { echo -s needs an address and file to download like ( www.boo.com/dir/file.zip ) | return }
  if ($left($1-,7) == http://) { %address = $gettok($1-,2,47) | %file = / $+ $gettok($1-,3-,47) }
  else { %address = $gettok($1-,1,47) | %file = / $+ $gettok($1-,2-,47) }
  set %download.address. [ $+ [ %sock ] ] %address
  sockopen %sock %address 80 
  sockmark %sock %file
}

on *:sockopen:download.*:{
  if ($sockerr) { echo -s *** socket error - $sockname - ( open ) }
  sockwrite -n $sockname GET $sock($sockname).mark HTTP/1.1
  sockwrite -n $sockname Host: %download.address. [ $+ [ $sockname ] ]
  sockwrite -n $sockname $crlf
  unset %download.address. [ $+ [ $sockname ] ]
}

on *:sockread:download.*:{
  var %sn = $sockname,%temp. [ $+ [ %sn ] ]
  if ($sockerr) { echo -s *** socket error - %sn - ( read ) | return }
  if (%download.binvar. [ $+ [ %sn ] ]) {
    sockread 8192 &temp. [ $+ [ %sn ] ]
    while ($sockbr) {
      bwrite $"($scriptdir $+ $nopath($sock(%sn).mark)) -1 -1 &temp. [ $+ [ %sn ] ]
      sockread 8192 &temp. [ $+ [ %sn ] ]
    }
  }
  else {
    sockread %temp. [ $+ [ %sn ] ]
    if (!%temp. [ $+ [ %sn ] ]) { set %download.binvar. [ $+ [ %sn ] ] $true }
    echo -s %temp. [ $+ [ %sn ] ]
  }
}
on *:sockclose:download.*:{
  echo -s $sockname just finished downloading $sock($sockname).mark
   unset %* [ $+ [ $sockname ] ] 
}
on *:exit:{ unset %download.*.* }
on *:start:{ unset %download.*.* }


--
GamerTag: maffew
How many hax0rz does it take to screw in a lightbulb? 1337
#40902 23/08/03 09:02 PM
Joined: Aug 2003
Posts: 3
D
Self-satisified door
Offline
Self-satisified door
D
Joined: Aug 2003
Posts: 3
maffew, uhm, ripping helpdesk tuts just owns hem ? smile


Link Copied to Clipboard