try. (1!:5 <jpath '~temp/wget') catch. 0 end.
can also be done by
mkdir_j_ '~temp/wget'

Sun, 03 Mar 2019, David Mitchell написал(а):
> Last try:
> foo=: 3 : 0
> try. (1!:5 <jpath '~temp/wget') catch. 0 end.
> tout=:dquote jpath jout=:'~temp/wget/out'
> cmd1=:dquote jpath '~tools/ftp/wget.exe'
> cmd2=:dquote jpath '~tools/ftp/busybox.exe'
> opts=:' -S -O',tout,' '
> api=:'http://api.stackexchange.com/2.2/answers/264298?order=desc&sort=activity&site=meta&filter=!.UDo6l2ikDi7iGlf'
> res=:spawn_jtask_ cmd1,opts,api
> if. +/'Content-Encoding: gzip' E. res do.
>  res=: spawn_jtask_  cmd2,' gunzip -ck ',tout
> end.
> ferase <tout
> ferase <jpath '~temp/wget'
> res
> )
> 
> On 3/3/2019 07:31, David Mitchell wrote:
> > Minor cleanup:
> > 
> > foo=: 3 : 0
> > try. (1!:5 <jpath '~temp/wget') catch. 0 end.
> > tout=:dquote jpath jout=:'~temp/wget/out'
> > cmd1=:dquote jpath '~tools/ftp/wget.exe'
> > cmd2=:dquote jpath '~tools/ftp/busybox.exe'
> > opts=:' -S -O',tout,' '
> > api=:'http://api.stackexchange.com/2.2/answers/264298?order=desc&sort=activity&site=meta&filter=!.UDo6l2ikDi7iGlf'
> > 
> > res=:spawn_jtask_ cmd1,opts,api
> > if. +/'Content-Encoding: gzip' E. res do.
> >   res=: spawn_jtask_  cmd2,' gunzip -ck ',tout
> > end.
> > ferase <jout
> > ferase <jpath '~temp/wget'
> > res
> > )
> > 
> > 
> > On 3/3/2019 07:09, David Mitchell wrote:
> > > Here is a more verbose approach that uses the wget returned response
> > > to determine if gunzip is needed:
> > > 
> > > foo=: 3 : 0
> > > tout=:dquote jpath jout=:'~temp/wget/out'
> > > tmsg=:dquote jpath '~temp/wget/msg'
> > > cmd1=:dquote jpath '~tools/ftp/wget.exe'
> > > cmd2=:dquote jpath '~tools/ftp/busybox.exe'
> > > opts=:' -S -O',tout,' '
> > > api=:'http://api.stackexchange.com/2.2/answers/264298?order=desc&sort=activity&site=meta&filter=!.UDo6l2ikDi7iGlf'
> > > 
> > > res=:spawn_jtask_ cmd1,opts,api
> > > if. +/'Content-Encoding: gzip' E. res do.
> > >   res=: spawn_jtask_  cmd2,' gunzip -ck ',tout
> > > end.
> > > ferase <jout
> > > res
> > > )
> > > 
> > > 
> > > On 3/2/2019 23:04, bill lam wrote:
> > > > use this,
> > > > 
> > > > load'web/gethttp'
> > > > 
> > > > api=:'http://api.stackexchange.com/2.2/answers/264298?order=desc&sort=activity&site=meta&filter=!.UDo6l2ikDi7iGlf'
> > > > 
> > > > 
> > > > (gethttp dquote api) spawn_jtask_ (dquote jpath
> > > > '~tools/ftp/busybox'),' gunzip -c'
> > > > 
> > > > {"items":[{"last_activity_date":1440639019,"answer_id":264298,"body_markdown":"Yes,....
> > > > 
> > > > 
> > > > The problem is not in wget or curl. wget in centos doesn't have
> > > > the --compression option either.
> > > > 
> > > > 
> > > > Sat, 02 Mar 2019, Nimp O написал(а):
> > > > > Thank you bill,
> > > > > 
> > > > > I tried piping the resulting binary stream to busybox within
> > > > > J but it gave me an error. I may be doing something wrong, I
> > > > > don't usually interact with J using shell commands.
> > > > > 
> > > > > shell (gethttp api),'|',jpath'~tools/ftp/busybox.exe gunzip'
> > > > > 
> > > > > |domain error: uucp
> > > > > 
> > > > > | 'r pi'=.0 _1{CreateProcessF 0;( uucp y);0;0;inh;f;0;0;si;pi
> > > > > 
> > > > > 
> > > > > Nevertheless, the equivalent line works in the windows command prompt.
> > > > > 
> > > > > 
> > > > > Despite this, maybe the ideal solution would be to update
> > > > > curl and wget binaries to support this form of
> > > > > decompression, avoiding the use of multiple shell utilities.
> > > > > 
> > > > > 
> > > > > Thanks.
> > > > > 
> > > > > ________________________________
> > > > > From: Programming <programming-boun...@forums.jsoftware.com>
> > > > > on behalf of bill lam <bbill....@gmail.com>
> > > > > Sent: Saturday, March 2, 2019 10:52 AM
> > > > > To: programm...@jsoftware.com
> > > > > Subject: Re: [Jprogramming] Decompressing gzip in J
> > > > > 
> > > > > You can use gunzip to decompress the data.
> > > > > 
> > > > > busybox.exe bundled in j807 should have this function.
> > > > > 
> > > > > Sat, 02 Mar 2019, bill lam написал(а):
> > > > > > Oh, I tried, stackexchange always responsed with gzip data even
> > > > > > wget had not asked. You need to add an extra option in wget
> > > > > > --compression=gzip
> > > > > > 
> > > > > > try use --compressed  if it is curl.
> > > > > > 
> > > > > > I think you are using windows because your api string won't work
> > > > > > on linux, shell will expand special character in it unless
> > > > > > quoted.
> > > > > > 
> > > > > > the wget.exe bundled in J are old and does not support the above
> > > > > > mentioned option, not sure about the curl.exe in the addon.
> > > > > > 
> > > > > > Sat, 02 Mar 2019, bill lam написал(а):
> > > > > > > If you are using a recent enough version of wget, it should
> > > > > > > automatically decompress data received.
> > > > > > > 
> > > > > > > Sat, 02 Mar 2019, Nimp O написал(а):
> > > > > > > > Hello everyone,
> > > > > > > > 
> > > > > > > > For educational purposes I'm trying to read a
> > > > > > > > JSON response from the StackOverflow API in J.
> > > > > > > > 
> > > > > > > > My current session is:
> > > > > > > > 
> > > > > > > > load'web/gethttp'
> > > > > > > > load'pjson'
> > > > > > > > 
> > > > > > > > 
> > > > > > > > api=:'http://api.stackexchange.com/2.2/answers/264298?order=desc&sort=activity&site=meta&filter=!.UDo6l2ikDi7iGlf'
> > > > > > > > 
> > > > > > > > 
> > > > > > > > gethttp api
> > > > > > > > 
> > > > > > > > �U��J1┌�_%F┌
> > > > > > > > 
> > > > > > > > ��┼┬��[�P�����Ŧ��
> > > > > > > > 
> > > > > > > > �M��ٶK黛]O�����s���&Y,� ...
> > > > > > > > 
> > > > > > > > 
> > > > > > > > The problem is that apparently the response is
> > > > > > > > gzipped. Does anyone know how can I accomplish
> > > > > > > > the decompression of this binary response inside
> > > > > > > > J?
> > > > > > > > 
> > > > > > > > I tried using the arc/zip and zlib addons with no success.
> > > > > > > > 
> > > > > > > > 
> > > > > > > > Thanks.
> > > > > > > > 
> > > > > > > > 
> > > > > > > > ----------------------------------------------------------------------
> > > > > > > > For information about J forums see 
> > > > > > > > http://www.jsoftware.com/forums.htm
> > > > > > > 
> > > > > > > -- 
> > > > > > > regards,
> > > > > > > ====================================================
> > > > > > > GPG key 1024D/4434BAB3 2008-08-24
> > > > > > > gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> > > > > > > gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
> > > > > > 
> > > > > > -- 
> > > > > > regards,
> > > > > > ====================================================
> > > > > > GPG key 1024D/4434BAB3 2008-08-24
> > > > > > gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> > > > > > gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
> > > > > 
> > > > > -- 
> > > > > regards,
> > > > > ====================================================
> > > > > GPG key 1024D/4434BAB3 2008-08-24
> > > > > gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
> > > > > gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
> > > > > ----------------------------------------------------------------------
> > > > > For information about J forums see http://www.jsoftware.com/forums.htm
> > > > > ----------------------------------------------------------------------
> > > > > For information about J forums see http://www.jsoftware.com/forums.htm
> > > > 
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to