The issue isn’t the lack of ps on Macos but the lack of a way to get *any* output from ps or pgrep on macOS when running the command in the context of a BaseXHTTP server running as a service.
The command execution works on the command line and when run say from the Base GUI but fails when run by the HTTP server. So I assume it’s something with how the server is running. Not a hard-stop issue for me, macOS is just for development, but I thought I’d ask in case I was missing some simple configuration or server start up detail. Cheers, E. _____________________________________________ Eliot Kimber Sr Staff Content Engineer O: 512 554 9368 M: 512 554 9368 servicenow.com<https://www.servicenow.com> LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow> From: Bridger Dyson-Smith <bdysonsm...@gmail.com> Date: Friday, October 20, 2023 at 9:02 AM To: Eliot Kimber <eliot.kim...@servicenow.com> Cc: BaseX <basex-talk@mailman.uni-konstanz.de> Subject: Re: [basex-talk] Trying to get process details on macOS [External Email] ________________________________ Ah, apologies ( that's what I get for trying to send emails during bedtime 🙂 ) I have been bitten in the past by arg differences between different Unix flavors. I have tried the following on Mac OS 12.something with just the BaseX jar download. let $ps := proc:execute('ps', ('-o', 'pid,%cpu,command')) return $ps <result> <output> PID %CPU COMMAND 82437 0.0 -bash 82462 16.7 /usr/bin/java -jar BaseX107.jar </output> <code>0</code> </result> This is a borrowed Mac - I didn't install anything. Does your Mac not have a ps; e.g. `which ps`? This one returns `/bin/ps`. Sorry for the noise. Best, Bridger On Thu, Oct 19, 2023, 8:00 PM Bridger Dyson-Smith <bdysonsm...@gmail.com<mailto:bdysonsm...@gmail.com>> wrote: Hi Eliot - hope you're well! Quickly off the cuff, the `ps` command on MacOS is a BSD-flavo(u)r, if I'm remembering correctly (it's been a while...). I don't have a Mac handy right now, but check this `ps` man page - https://ss64.com/osx/ps.html<https://ss64.com/osx/ps.html> - your args may need to be adjusted. Hope that's helpful. Best, Bridger On Thu, Oct 19, 2023, 7:08 PM Eliot Kimber <eliot.kim...@servicenow.com<mailto:eliot.kim...@servicenow.com>> wrote: In the context of a 10.6 server running as a web app, I’m trying to implement a function that uses the process module to run commands to get information about the running BaseX servers, in particular, the PID and port each server is on. I start a number of “worker” BaseXHTTP instances to handle long-running processes. On Linux this code works: let $cmdResult := proc:execute(‘ps’, ('-o', 'pid,%cpu,command')) From which I can parse out the PID and port for BaseX processes: let $lines as xs:string* := ($cmdResult/output/text() => tokenize('
')) return map{ 'data' : let $servers as map(*) := map:merge( for $line at $p in $lines[contains(., 'BaseXHTTP')] let $pid as xs:string := tokenize($line, '\s+')[1] let $port as xs:string := tokenize(substring-after($line, ' -p'),'\s+')[1] return map{ $port : map{ 'port' : $port, 'pid' : $pid } } ) return $servers } However, on macOS there’s not an exact equivalent of the linux version of ps, but there is the “pgrep” command, which, from the command line, lets me get the data I need: pgrep -lf basex However, when I try to run this from within BaseX, I get “sysmon request failed with error: sysmond service not found pgrep: Cannot get process list” I assume this is a function of how the HTTP servers are running on macOS. I’m starting them like so: "${basexBinDir}/basexhttp" ${debugFlag} -S -p${clientPort} -h${httpPort} -s${stopPort} & So as a service Any ideas how I might make this work on mapOS? Thanks, Eliot _____________________________________________ Eliot Kimber Sr Staff Content Engineer O: 512 554 9368 M: 512 554 9368 servicenow.com<https://www.servicenow.com> LinkedIn<https://www.linkedin.com/company/servicenow> | Twitter<https://twitter.com/servicenow> | YouTube<https://www.youtube.com/user/servicenowinc> | Facebook<https://www.facebook.com/servicenow>