This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

http get

Old posts that have not been replied to for several years.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

http get

Post by Ofloo »

i get error
[01:25] Tcl error [down:pub]: invalid command name "http::geturl"

Code: Select all

bind pub m !down down:pub

proc down:pub {nick uhost hand chan arg} {
puts [http::data [http::geturl [lindex $arg 0]] -binary boolean ]
}
how do i use this ? ive read the manual but still noob at syntax also tryed to define it as a var but euhm .. not working
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Consult again the manual..
Once the game is over, the king and the pawn go back in the same box.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

First you need to import the http package into memory.

It is simalar to loading a Tcl script. See the manual on yhow to do this (yes it is there, near the top).

In adition, I would reconsider what you are doing with http::geturl command.

In your script, you use it to directly output to a file, using http::data.

There are two problems with this.

1: The puts command requires a channel name. You havn't given it one (only the data).

2: Once the script is complete, the http data will remain in memory. You need to call http::cleanup on the returned token. Thus you need to store that token.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

i loaded http.tcl as a tcl script but still getting this stuff .. i know but euhm what your telling me is realy technical stuff witch i don't understand verry well .. :/ just a noob .. <- me so could you give an example ? would be great full
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

if i read well i don't need to load http 2.4 cause it is a thing that is loaded in the tcl core i checked lib and it was there.. i checked syntax manual at http://mini.net/tcl/1475 and it showed the syntax i was using but i still get an error
[01:30] Tcl error [update:pub]: wrong # args: should be "::http::geturl url args"
so what am i doing wrong ?

it just needs to download a file that is it an binairy file

Code: Select all

bind pub m !update update:pub

proc down:pub {nick uhost hand chan arg} {
set url [lindex $arg 0]
puts [http::data [http::geturl $url -binary boolean]]
}
i understand what you mean by outputting the file now you mention it it sounds logic is there an other way on doing this ?

what do you recommend but easy and simple so i can understand.

i also tryed "source path/http.tcl"
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

anny one ??
XplaiN but think of me as stupid
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Are you blind or plain stupid? The *error* says what you should do.. seesh!
Once the game is over, the king and the pawn go back in the same box.
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

Sorry i don't know it and like your quote used to say that it is best xplained by ignorence well i have no clue if you know it suggestions what i read ive read ive tryed, maybe i missed something , maybe i misunderstood, but your answer doesn't make me any wizer then i allready was :/
XplaiN but think of me as stupid
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Doh! use ::http::geturl not http::geturl ..
Once the game is over, the king and the pawn go back in the same box.
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

caesar wrote:Doh! use ::http::geturl not http::geturl
That's not it. Read the error message :P (wrong # args)

Prefixing the namespace name with :: is only needed if you're executing code in a differen namespace than the parent and a namespace by that same name exists but is not the one you want.
...uhm :P Was that even remotely clear?
User avatar
caesar
Mint Rubber
Posts: 3778
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Damn.. Ignore my previous reply. I think I'll take a lil vacation or something, I've had some way to screwd up days this week..
Once the game is over, the king and the pawn go back in the same box.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

Code: Select all

set url [lindex $arg 0] 
first line of bad coding... ALWAYS make sure it is actually a LIST you are doing the list command on ;)

Code: Select all

puts [http::data [http::geturl $url -binary boolean]]
second line ;)
first of as ppslim said.. you need to put it somewhere, open a file to put it in..

-binary boolean <--- change that to -binary 1
also it might be a good idea to do http::cleanup at the end ...and a timeout on the connection to maybe?

so the final code would look something like this:

Code: Select all

bind pub m !update update:pub 

proc down:pub {nick uhost hand chan arg} { 
  set url [lindex [split $arg] 0] 
  set fid [open somefile w+]
  set body [http::data [set token [http::geturl $url -binary 1 -timeout 9999]]]
  puts $fid $body
  catch {close $fid}
  http::cleanup $token
}
Elen sila lúmenn' omentielvo
User avatar
user
&nbsp;
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Papillon wrote:

Code: Select all

catch {close $fid}
There's no need to catch close. Do you have any particular reason for doing it? (I've seen you do it in other posts too iirc)
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

I use it mainly as a error prevention. No hurt in removing it... just old habit I guess :)
Elen sila lúmenn' omentielvo
O
Ofloo
Owner
Posts: 953
Joined: Tue May 13, 2003 1:37 am
Location: Belguim
Contact:

Post by Ofloo »

First of all tnx verry mutch.

hmm i think i start to understand

ah so i need to say what the file will be called hmm ok sounds logic didn't think of that, tought the lib handled that and time out aswell :/ hehe

the time-out i know what it is for just wondering why like this:

you sad before for time out use cleanup, but you do it on the end while the time out is defined in the url

i am not critising just trying to understand it. beter make it logic ;-)

to understand beter what you mean whould this bepossible i mean cause a list command is just like arg and all that is after it so if i would wana name the file it would need to be able to name it and i could do this by setting the first arg to an normal not list command if i did it just would it include in the url write ??? or am i wrong.

Code: Select all

source lib/tcl8.4/http2.4/http.tcl

bind pub m !update update:pub 

proc update:pub {nick uhost hand chan arg} { 
  set out [lindex $arg 0]
  set url [lindex [split $arg] 1] 
  set fid [open $out w+] 
  set body [http::data [set token [http::geturl $url -binary 1 -timeout 9999]]] 
  puts $fid $body
  close $fid 
  http::cleanup $token 
  putquick "NOTICE $nick :Download complete."
}
i removed the catch cause it kept the file open (couldn't be executed or anything) but i got an other problem, if i check byte size the file is the same, but if i compare them with a hex the new file is little bigger. meaning it has crc errors, i also tryed binary 0 and left it out but no results, ive tryed wiht catch and without.. i added the notice cause like this i could see if all was done so it didn't stop somewhere. i tought the binary was there to prevent crc in compressed or executable files :/


ok like i tought it downloaded it in ascii cause when i download it with or without the -binary 1 it doesn't make a difference and strange enough these apear to be equal so ..., this means to me that it is downloading it in ascii even tho you define it to be binary.
XplaiN but think of me as stupid
Locked