<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/18590" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2011-08-15T10:20:49-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/18590</id>

		<entry>
		<author><name><![CDATA[Ofloo]]></name></author>
		<updated>2011-08-15T10:20:49-04:00</updated>

		<published>2011-08-15T10:20:49-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=97420#p97420</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=97420#p97420"/>
		<title type="html"><![CDATA[zlib tclsh8.6]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=97420#p97420"><![CDATA[
<blockquote class="uncited"><div>$ ./zlib_test.tcl<br>An error occured while fetching http://: corrupted input data<br>$ gunzip /tmp/file.gz<br>$ ls /tmp/file  <br>/tmp/file<br>$ </div></blockquote><div class="codebox"><p>Code: </p><pre><code>#!/usr/local/bin/tclsh8.6package require httppackage require zlibset url {http://}set tok [http::geturl $url -binary 1]set dat [http::data $tok]http::cleanup $tokif {![catch {open /tmp/file.gz w} w]} {  fconfigure $w -translation binary -encoding binary  puts -nonewline $w $dat  close $w}if {[catch {zlib decompress $dat} dcd]} {  puts "An error occured while fetching $url: $dcd"}</code></pre></div>EDIT<br><br>an other thing i noticed is that when you use tcl 8.6 that you're not supposed to add package require zlib<br><div class="codebox"><p>Code: </p><pre><code>#!/usr/local/bin/tclsh8.6package require httpset url {http://narf.ofloo.net/file.gz}set tok [http::geturl $url -binary 1]set dat [http::data $tok]http::cleanup $tokif {![catch {open /tmp/file.gz w} w]} {  fconfigure $w -translation binary -encoding binary  puts -nonewline $w $dat  close $w}</code></pre></div>otherwise it will not have the option zlib gunzip however the result is exactly the same though. And an other surprise it did a decompression. However this is a test file, .. and the link i'm getting doesn't contain the file name which results back into the same error.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3151">Ofloo</a> — Mon Aug 15, 2011 10:20 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2011-08-15T09:25:55-04:00</updated>

		<published>2011-08-15T09:25:55-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=97418#p97418</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=97418#p97418"/>
		<title type="html"><![CDATA[zlib tclsh8.6]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=97418#p97418"><![CDATA[
Well, posting the actual error message is usually helpful..<br><br>That said, you've enclosed your "set" command within brackets, and then pass the output to "catch" for evaluation. Unless you were intending to execute the whole text on the webpage as a single tcl-command, this is probably your problem. Even if this is what you intended, be adviced that the text received is used explicitly as the command; you will not be able to pass arguments this way.<br><br>I'd also recommend using the error/result-variable option with catch, so that you can actually see the error you're trying to catch...<br><br>All in all, I'd probably re-write that piece something like this:<div class="codebox"><p>Code: </p><pre><code>package require httppackage require zlibset url "http://"set tok [http::geturl $url -binary 1]set dat [http::data $tok]http::cleanup $tokif {[catch {zlib decompress $dat} dcd]} {  #Something went wrong, the error message is available in dcd  putlog "An error occured while fetching $url: $dcd"} else {  #Everything went smoothly.. do whatever you need with the data in dcd  #Should you desire to execute the content of $dcd as a valid tcl command line, uncommend the following line:  #catch {eval $dcd} result}</code></pre></div>Be adviced, I've intentionally left out the set command within the catch argument, as it is not needed.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Mon Aug 15, 2011 9:25 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Ofloo]]></name></author>
		<updated>2011-08-15T07:54:07-04:00</updated>

		<published>2011-08-15T07:54:07-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=97417#p97417</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=97417#p97417"/>
		<title type="html"><![CDATA[zlib tclsh8.6]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=97417#p97417"><![CDATA[
how do i decompress gzip file from url<div class="codebox"><p>Code: </p><pre><code>package require httppackage require zlibset url "http://"set tok [http::geturl $url -binary 1]set dat [http::data $tok]http::cleanup $tokcatch {[set dcd [zlib decompress $dat]]}</code></pre></div>this errors<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=3151">Ofloo</a> — Mon Aug 15, 2011 7:54 am</p><hr />
]]></content>
	</entry>
	</feed>
