From owner-freebsd-stable@FreeBSD.ORG Sat Dec 22 11:32:32 2007 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 51B1F16A41A for ; Sat, 22 Dec 2007 11:32:32 +0000 (UTC) (envelope-from lists@lozenetz.org) Received: from mail.webreality.org (mailserver.webreality.org [217.75.141.5]) by mx1.freebsd.org (Postfix) with ESMTP id 19FB213C4E1 for ; Sat, 22 Dec 2007 11:32:31 +0000 (UTC) (envelope-from lists@lozenetz.org) Received: from [192.168.224.203] (unknown [77.78.9.203]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.webreality.org (Postfix) with ESMTP id D59CDFFE333; Sat, 22 Dec 2007 13:07:27 +0200 (EET) Message-ID: <476CEFE7.3060402@lozenetz.org> Date: Sat, 22 Dec 2007 13:07:19 +0200 From: Anton - Valqk User-Agent: Icedove 1.5.0.14pre (X11/20071018) MIME-Version: 1.0 To: freebsd-stable@FreeBSD.ORG, 000.fbsd@quip.cz, lists@lozenetz.org References: <200712201741.lBKHfDRb069152@lurza.secnetix.de> In-Reply-To: <200712201741.lBKHfDRb069152@lurza.secnetix.de> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-HostIT-MailScanner-Information: Please contact the ISP for more information X-HostIT-MailScanner: Found to be clean X-HostIT-MailScanner-From: lists@lozenetz.org Cc: Subject: Re: jlogin.sh - a small nice jails helper! X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Dec 2007 11:32:32 -0000 Hi there, your script didn't had what I wanted for the ps, that's why I wrote simpler one for myself, that's do the job for me - finds a string from ps axu from any jail :) here it is, hopes it's useful (quick 15mins hack script). #!/bin/sh #list all jails processes #$1 - jid - jail pattern || ALL #$2 - string in jail ps axu cmd if [ -n "$2" ]; then psFilter="grep $2" fi if [ -n "$1" ] && [ "$1" != "ALL" ]; then jName=$1 jID=`jls | grep $jName|awk '{print $1}'` jRealName=`jls |grep $jName|awk '{print $3}'` echo "Listing processes for $jRealName ( $jID )..." if [ -n "$psFilter" ]; then jexec $jID ps axu|$psFilter else jexec $jID ps axu fi else for jID in `jls|awk '{print $1}'`; do if [ "$jID" -gt 0 ]; then jRealName=`jls|grep $jID|awk '{print $3}'` echo "Listing processes for $jRealName ( $jID )..." if [ -n "$psFilter" ]; then jexec $jID ps axu|$psFilter else jexec $jID ps axu fi fi done fi Oliver Fromme wrote: > Miroslav Lachman wrote: > > It is nice idea, but I think you should have a better scripting style ;) > > Yes, it almost looked like perl. :-) > May I suggest a few further improvements? > > > login_shell="/bin/tcsh" > > I certainly wouldn't want tcsh. How about looking at > $SHELL, and if it doesn't exist, then fall back to the > standard shell (which is /bin/sh). > > Also, the last command (jexec) should be preceded by > "exec" so the shell doesn't hang around. So the last > part of the script would look like this: > > jail_path=$(jls | awk '$1=='$jail_id' {print $4}') > > if [ -z "$SHELL" -o ! -x "$jail_path/$SHELL" ]; then > login_shell="$SHELL" > else > login_shell="/bin/sh" > fi > > echo "Logging in to $jail_hostname" > exec jexec $jail_id $login_shell > > Best regards > Oliver > > PS: By the way, here's another useful script that displays > processes running in jails, ordered by jail IDs: > > http://www.secnetix.de/~olli/scripts/jps > > -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.