mIRC Homepage
Posted By: bunar kinda hard - 25/12/03 03:08 AM
i am interested in some huge help.

what i want is an updater... yeh i know you heard a lod of this BUT i just want for specific things code:

when i click on BUTTON of dialog it connects for example on
www.script.com and downloads .exe file and after download it runs that .exe file

if someone could provide me a full code for this (coz i know there are socket codes, filesys codes coz of directory and all that) and i dont know any of that !

OR some link to a script that does simmiliar would be VERY appreciated !

regards, merry x-mas, eat much, be lazy, get fat layers on your body & enjoy the party !
Posted By: KingTomato Re: kinda hard - 25/12/03 03:38 AM
this should work:

Code:
alias getexe {
  var %url = $remove($1-, http://)
  var %site = $gettok(%url, 1, $asc(/))
  var %file = $iif($remove(%url, %site), $ifmatch, /) 

  /sockopen download %site 80
  /sockmark download %file
  /set -u10 %download.head
}

on *:SOCKOPEN:download: {
  if ($sockerr) /echo -s Could not connect to server
  else {
    var %file = $sock($sockname).mark
    /sockwrite -n $sockname GET %file HTTP/1.0
    /sockwrite -n $sockname Host: $sock($socknamer).ip
    /sockwrite -n $sockname $crlf
    if ($isfile($gettok(%file, -1, $asc(/)))) .remove $gettok(%file, -1, $asc(/))
  }
}

on *:SOCKREAD:download: {
  if (%download.head) {
    /sockread %data
    if (%data == $null) {
      /unset %download.head
      /echo -s Downloading...
    }
  }
  else {
    var %file = $gettok($sock($sockname).mark, -1, $asc(/))
    /sockread &data
    /bwrite %file -1 -1 &data
  }
}

on *:SOCKCLOSE:download: {
  /echo -s File Downloaded
}


/getexe <path-to-exe>

/getexe http://www.somesite.com/path/to/somefile.exe

then the file will be downloaded, and saved as "somefile.exe", or whatever the name of the file you downloaded is.
Posted By: bunar Re: kinda hard - 25/12/03 03:56 AM
wow, you are my savior !

will this work for any mirc version (from 6.12 and backwards) or just for this newest?
and how to control in what folder to dl just that specificed file (not global as mirc\downloads changed to something else) ?
Posted By: KingTomato Re: kinda hard - 25/12/03 04:24 AM
it should work for 6.x and probably 5.9 It downlaods to the root directory, but to change it you can make two modifications.

1. In the on sockopen even, where the if ($isfile(...)) .remove ... Add a path just after the .remove like:
if ($isfile(...)) .remove blah -becomes- if ($isfile(...)) .remove dir\ $+ blah
2. On the /bwrite %file, change it to /bwrite dir\ $+ %file
© mIRC Discussion Forums