[Jprogramming] Linux, J and reading /proc
Jon Hough
jghough at outlook.com
Fri Jun 19 00:49:11 UTC 2015
Thanks!
> Date: Wed, 17 Jun 2015 10:47:54 -0400
> From: joebogner at gmail.com
> To: programming at jsoftware.com
> Subject: Re: [Jprogramming] Linux, J and reading /proc
>
> I am going to guess it won't read because the file size is reported as 0
>
> (1!:0) <'/proc/net/sockstat'
> ┌────────┬──────────────────┬─┬───┬──────┬──────────┐
> │sockstat│2015 6 17 14 46 17│0│r--│r-----│-r--r--r--│
> └────────┴──────────────────┴─┴───┴──────┴──────────┘
>
> You can execute host commands through 2!:0 on linux (no jtask needed)
>
> [ t=:(2!:0) 'cat /proc/net/sockstat'
> sockets: used 96
> TCP: inuse 9 orphan 0 tw 0 alloc 12 mem 2
> UDP: inuse 0 mem 0
> UDPLITE: inuse 0
> RAW: inuse 0
> FRAG: inuse 0 memory 0
>
> On Wed, Jun 17, 2015 at 10:10 AM, Jon Hough <jghough at outlook.com> wrote:
>
> > In J, is there a way to read /proc files in Linux (for example to get
> > network stats, or process info etc)?(/proc info:
> > http://www.tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html )
> >
> > For example, in Python, if I wanted to read sockstat, I might do:
> >
> > def get_info(path): f = open(path,'r') return
> > f.readlines()
> >
> >
> > if __name__ == '__main__':
> > map(lambda x: print(x), get_info('/proc/net/sockstat'))
> >
> > In J, to get the same functionality I am using
> >
> > ]data =. spawn_jtask_ 'cat /proc/net/sockstat'
> >
> >
> > Is there a way to get this information without using Jtask?
> > 1!:1 does not work, but is there another verb to do this?
> >
> >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
More information about the Programming
mailing list