[tex-live] *** GMX Spamverdacht *** Re: TeXLive (Windows) bash script -> exe

Reinhard Kotucha reinhard.kotucha at web.de
Wed May 21 04:22:39 CEST 2014


On 2014-05-20 at 17:37:26 +0200, Josef Kleber wrote:


--  > Am 20.05.2014 15:27, schrieb Norbert Preining:
 > > On Tue, 20 May 2014, Josef Kleber wrote:
 > >> That seems to be the last problem. If i comment the getopt parts,
 > >> 'texlua osmimage.lua' uses the default values and downloads the
 > >> expected map.
 > >
 > > Can you send me the final code, then I can see how it can be easily
 > > included so that the getopt part works.
 > 
 > osmimage.lua attached.
 > 
 > This works for me with wget, but i was unable to integrate the 
 > 'http.request' method that worked in another test.
 > 
 > Josef

This doesn't work:

 > PROGLINE = "wget '" .. IMGURL .. "' -O " .. UOFILE
 > os.spawn(PROGLINE)

Windows doesn't understand single quotes.  You have to use double
quotes on Windows.  os.type is your friend.  It returns "unix" on Unix
and "windows" on Windows.  You have to treat Unix and Windows command
lines differently here.

Another issue:
wget isn't in PATH on Windows.  You have to provide the path to wget
yourself. 

local function wget ()
  local WGET 
  if os.type == 'windows' then
    local texmf_root = kpse.var_value('TEXMFROOT')
    WGET = texmf_root .. '/tlpkg/installer/wget/wget.exe'
  else
    WGET='wget'
  end  
  return WGET
end

 > -- TO BE DONE TODO TODO TODO
 > -- if [ "$QUIET" = "true" ]
 > -- then
 > --   exec 1>/dev/null
 > --   exec 2>/dev/null
 > -- fi

In order to suppress stdout, simply read the output of wget from a
pipe.  Just use io.popen() instead of os.spawn().

 > -- local file = ltn12.sink.file(io.open(UOFILE, 'wb'))
 > -- http.request {
 >     -- url = IMGURL,
 >     -- sink = file,
 > -- } 
 > -- gives <html><body><b>Http/1.1 Bad Request</b></body> </html> instead of image
 > -- URL encoding for LOCATION??? but works for wget

Maybe a problem with special characters.  I recommend to transform all
special chars in IMGURL to hex i.e., replace "&" with "%26".
Otherwise it would be more difficult to support different operating
systems.

And if you are running your script in an arbitry directory for
testing, (no symlinks or wrappers involved), add the line

  kpse.set_program_name('texlua')

to your script and things like

   require ("alt_getopt") 

will work.


How do you handle character encodings?

  LOCATION = "Bergheimer Straテoテηクe 110A, 69115 Heidelberg, Germany"  

Regards,
  Reinhard

----------------------------------------------------------------------------
Reinhard Kotucha                                      Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover                              mailto:reinhard.kotucha at web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------




More information about the tex-live mailing list