Since time immemorial I have used the ps command to get information about processes from the shell. Under Ventura the ps command works in the Terminal. But for the shell I get an error
bash: /usr/bin/ps: No such file or directory
So how do I replace the command? My Goggle fu told me that I could use the top command. But I can’t get it to working in Xojo.
dim theShell as new Shell
theShell.Execute "/usr/bin/top|grep vserver_x64"
if theShell.ExitCode <> 0 then
MessageBox "problem with shell"
Return
end if
The above code just hangs. If I use the -n 1 option it doesn’t even do anything in the Terminal.
Any other ideas? I need to check if Valentina Server is running or not.
-l <samples>
Use logging mode and display samples, even if
standard output is a terminal. 0 is treated as infinity.
Rather than redisplaying, output is periodically printed in
raw form. Note that the first sample displayed will have an
invalid %CPU displayed for each process, as it is calculated
using the delta between samples.
top is great for figuring out what is sucking your Mac’s CPU dry, normally now some errant Apple sub process.
You may be able to using NSWorkspace and NSRunningApplications to get at vserver_x64, much quicker than using a shell instance, however NSRunningApplications doesn’t list all processes.