Login  Register

Re: Get OS uptime

Posted by EstebanLM on Mar 19, 2015; 10:01am
URL: https://forum.world.st/Get-OS-uptime-tp4813047p4813115.html

'/proc/uptime' asFileReference readStreamDo: [ :stream | stream contents ].

is better way.

but you will still get an empty string because actually ‘/proc’ does not contains real files… so the file plugin does not applies there (and is another debate if it should…)

you should use OSProcess instead (installable from Configurations Browser)

(PipeableOSProcess command: 'uptime') upToEndOfFile.

Esteban

> On 19 Mar 2015, at 07:07, Julien Delplanque <[hidden email]> 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
>