<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">2014-05-21 4:22 GMT+02:00 Reinhard Kotucha <span dir="ltr"><<a href="mailto:reinhard.kotucha@web.de" target="_blank">reinhard.kotucha@web.de</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 2014-05-20 at 17:37:26 +0200, Josef Kleber wrote:<br>
<br>
<br>
-- > Am 20.05.2014 15:27, schrieb Norbert Preining:<br>
<div><div class="h5"> > > On Tue, 20 May 2014, Josef Kleber wrote:<br>
> >> That seems to be the last problem. If i comment the getopt parts,<br>
> >> 'texlua osmimage.lua' uses the default values and downloads the<br>
> >> expected map.<br>
> ><br>
> > Can you send me the final code, then I can see how it can be easily<br>
> > included so that the getopt part works.<br>
><br>
> osmimage.lua attached.<br>
><br>
> This works for me with wget, but i was unable to integrate the<br>
> 'http.request' method that worked in another test.<br>
><br>
> Josef<br>
<br>
</div></div>This doesn't work:<br>
<br>
> PROGLINE = "wget '" .. IMGURL .. "' -O " .. UOFILE<br>
> os.spawn(PROGLINE)<br>
<br>
Windows doesn't understand single quotes. You have to use double<br>
quotes on Windows. os.type is your friend. It returns "unix" on Unix<br>
and "windows" on Windows. You have to treat Unix and Windows command<br>
lines differently here.<br>
<br>
Another issue:<br>
wget isn't in PATH on Windows. You have to provide the path to wget<br>
yourself.<br>
<br>
local function wget ()<br>
local WGET<br>
if os.type == 'windows' then<br>
local texmf_root = kpse.var_value('TEXMFROOT')<br>
WGET = texmf_root .. '/tlpkg/installer/wget/wget.exe'<br>
else<br>
WGET='wget'<br>
end<br>
return WGET<br>
end<br>
<br>
> -- TO BE DONE TODO TODO TODO<br>
> -- if [ "$QUIET" = "true" ]<br>
> -- then<br>
> -- exec 1>/dev/null<br>
> -- exec 2>/dev/null<br>
> -- fi<br>
<br>
In order to suppress stdout, simply read the output of wget from a<br>
pipe. Just use io.popen() instead of os.spawn().<br></blockquote><div><br></div><div>Windows have nul (with one l), not /dev/null <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> -- local file = ltn12.sink.file(io.open(UOFILE, 'wb'))<br>
> -- http.request {<br>
> -- url = IMGURL,<br>
> -- sink = file,<br>
> -- }<br>
> -- gives <html><body><b>Http/1.1 Bad Request</b></body> </html> instead of image<br>
> -- URL encoding for LOCATION??? but works for wget<br>
<br>
Maybe a problem with special characters. I recommend to transform all<br>
special chars in IMGURL to hex i.e., replace "&" with "%26".<br>
Otherwise it would be more difficult to support different operating<br>
systems.<br>
<br>
And if you are running your script in an arbitry directory for<br>
testing, (no symlinks or wrappers involved), add the line<br>
<br>
kpse.set_program_name('texlua')<br>
<br>
to your script and things like<br>
<br>
require ("alt_getopt")<br>
<br>
will work.<br>
<br>
<br>
How do you handle character encodings?<br>
<br>
LOCATION = "Bergheimer Straテoテηクe 110A, 69115 Heidelberg, Germany"<br>
<br>
Regards,<br>
Reinhard<br>
<br>
----------------------------------------------------------------------------<br>
Reinhard Kotucha Phone: <a href="tel:%2B49-511-3373112" value="+495113373112">+49-511-3373112</a><br>
Marschnerstr. 25<br>
D-30167 Hannover mailto:<a href="mailto:reinhard.kotucha@web.de">reinhard.kotucha@web.de</a><br>
----------------------------------------------------------------------------<br>
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.<br>
----------------------------------------------------------------------------<br>
<br>
<br>
</blockquote></div><br><br clear="all"><br>-- <br>Zdeněk Wagner<br><a href="http://hroch486.icpf.cas.cz/wagner/" target="_blank">http://hroch486.icpf.cas.cz/wagner/</a><br><a href="http://icebearsoft.euweb.cz" target="_blank">http://icebearsoft.euweb.cz</a>
</div></div>