Re: Get OS uptime
Posted by
Michal Balda on
Mar 19, 2015; 2:09pm
URL: https://forum.world.st/Get-OS-uptime-tp4813047p4813224.html
Hi,
your solution does not work because files in /proc are virtual and have
no size (their size will be reported as 0).
FileStream>>contents sends #size to determine the length and that will
return 0 for all files in /proc.
So the solution is to use something that does not use #size, like:
(FileLocator root / 'proc' / 'uptime') readStream upToEnd
Michal
On 19.3.2015 07:07, Julien Delplanque wrote:
> Hi everyone,
>
> I can't find out how to get the uptime of the OS from pharo.
>
> I tried:
>
> (FileLocator root / 'proc' / 'uptime') readStream contents.
>
> and
>
> (FileSystem disk root / 'proc' / 'uptime') readStream contents.
>
> but all what I get is an empty string ''.
>
> I don't know if there are messages in some specific classes to do this
> (in OSProcess for example?).
>
> Thanks in advance.
>
> Julien
>