I tried that, but my scenario is that I'm logged into a machine via ssh. It would still be an interactive session, but there is no console on which to show any graphics.
Regards, Roger Herikstad > On 3 Mar, 2014, at 20:20, Tim Holy <[email protected]> wrote: > > There's a function `isinteractive` already in base, does it solves the same > problem? > > --Tim > >> On Sunday, March 02, 2014 10:31:16 PM Roger Herikstad wrote: >> Hi list, >> While running some code in parallel on my Mavericks system using Julia >> Version 0.3.0-prerelease+1741, I needed to prevent importing Tk if the >> current user did not have a console session, as this would crash the worker >> processes. In case it might be of general interest, this was my solution: >> >> function hasgui() >> username = split(readall(`who am i`))[1] >> return hasgui(username) >> end >> >> function hasgui(username::String) >> s = readall(`who`) >> return ismatch(Regex("$username[ \t]* console"),s) >> end
