From owner-freebsd-questions@FreeBSD.ORG Thu Oct 30 14:14:16 2008 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D5E30106564A for ; Thu, 30 Oct 2008 14:14:16 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from mail.rachie.is-a-geek.net (rachie.is-a-geek.net [66.230.99.27]) by mx1.freebsd.org (Postfix) with ESMTP id 9D5688FC1D for ; Thu, 30 Oct 2008 14:14:16 +0000 (UTC) (envelope-from fbsd.questions@rachie.is-a-geek.net) Received: from localhost (mail.rachie.is-a-geek.net [192.168.2.101]) by mail.rachie.is-a-geek.net (Postfix) with ESMTP id 9335EAFCF5B; Thu, 30 Oct 2008 06:14:15 -0800 (AKDT) From: Mel To: freebsd-questions@freebsd.org Date: Thu, 30 Oct 2008 15:14:13 +0100 User-Agent: KMail/1.9.7 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200810301514.13932.fbsd.questions@rachie.is-a-geek.net> Cc: Eduardo Meyer Subject: Re: Script-friendly (parseble) ps(1) output? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2008 14:14:16 -0000 On Wednesday 29 October 2008 23:02:43 Eduardo Meyer wrote: > ps -ax -o pid -o user -o emul -o lstart -o lockname -o stat -o command First of all you will want -ww, since the command will otherwise be truncated. Secondly, you can comma seperate the -o arguments for brevity, so: ps -awwx -o pid,user,emul,lstart,lockname,stat,command will be your command. You forgot to mention what language your CGI will be in, so I'll just give you the simplest algorithm: - read the first line - record position of the first character after a space character, by simply walking the line char by char - Using those positional numbers it is now trivial to extract the information from the rest of the lines. -- Mel Problem with today's modular software: they start with the modules and never get to the software part.