home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2001 February
/
PCWorld_2001-02_cd.bin
/
Software
/
Vyzkuste
/
visirc
/
fetch.vsc
< prev
next >
Wrap
Text File
|
1997-08-29
|
2KB
|
44 lines
// FETCH.VSC (Version 1.10) - Usage: /fetch url
// A great little script to grab files off the Web.
//
// Example: /fetch http://www.megalith.co.uk/vircblu3.jpg
//
// This script demonstrates how to "hijack" a TDCC file transfer socket and
// send a GET request to a web server. V97 is totally unaware of this, and
// downloads the file as if it was a regular file being received by TDCC.
// This script also demonstrates some rather complex use of the list
// manipulation functions to parse a URL into its different components.
Alias FETCH
@l $url = $listSplit(/ $1-)
@l $protocol = $listIndex(0 $url)
if ([$protocol] != [http:])
TextOut > . clRed *** I can only fetch files from http sites at the moment!!
Halt
endif
@l $site = $listIndex(2 $url)
@l $wholefile = $listJoin(/ $listRange(3 $listElementCount($url) $url))
@l $file = $listIndex($($listElementCount($url) - 1) $url)
TextOut > . clBlue *** Fetching file \b$file\b from \b$site\b ...
SimulateServerData :www!www@$site PRIVMSG $N :\ADCC TSEND $file $dns($site) 80\A
@l $socket = $MapObject(*TGET/www/$file:DCCSocket)
@l $status = $MapObject(*TGET/www/$file:txStatus)
TextOut > . clBlack $socket $status
// We need to wait until the socket has actually connected before sending the
// GET request.
TextOut > . clBlue *** Waiting for socket to connect ...
@l $stime = $mtime()
while ([$prop($status.Caption)] != [Transferring ...])
Yield
// Check that the DCC form hasn't closed due to an error.
if (!($MappedObjectExists(*TGET/www/$file)))
TextOut > . clRed *** An error occurred while connecting to \b$site\b.
Halt
endif
endwhile
$socket.SendCRLF GET /$wholefile
TextOut > . clBlue *** Transferring ...
EndAlias