WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-bugs

[Xen-bugs] [Bug 1266] New: xendomains init.d script using cut

To: xen-bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-bugs] [Bug 1266] New: xendomains init.d script using cut
From: bugzilla-daemon@xxxxxxxxxxxxxxxxxxx
Date: Wed, 28 May 2008 13:55:44 -0700
Delivery-date: Wed, 28 May 2008 13:56:00 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-bugs-request@lists.xensource.com?subject=help>
List-id: Xen Bugzilla <xen-bugs.lists.xensource.com>
List-post: <mailto:xen-bugs@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-bugs>, <mailto:xen-bugs-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-bugs>, <mailto:xen-bugs-request@lists.xensource.com?subject=unsubscribe>
Reply-to: bugs@xxxxxxxxxxxxxxxxxx
Sender: xen-bugs-bounces@xxxxxxxxxxxxxxxxxxx
http://bugzilla.xensource.com/bugzilla/show_bug.cgi?id=1266

           Summary: xendomains init.d script using cut
           Product: Xen
           Version: 3.0.1
          Platform: Unspecified
        OS/Version: Linux
            Status: NEW
          Severity: minor
          Priority: P2
         Component: Tools
        AssignedTo: xen-bugs@xxxxxxxxxxxxxxxxxxx
        ReportedBy: kai@xxxxxxxxxxxxx


/etc/init.d/xendomains came with the xen rpms for Centos 5.1. The parseln
function uses cut to yank out the first 17 characters of the report from xm
list in order to separate the domain's Name from the rest of the list.
It looks like somebody tried this:
parseln()
{
    read name id mem cpu vcpu state tm < <(echo "$1")
}
But found that problematic when you had domains with spaces in the name. So it
was changed to:
parseln()
{
    name=`echo "$1" | cut -c0-17`
    name=${name%% *}
    rest=`echo "$1" | cut -c18- `
    read id mem cpu vcpu state tm < <(echo "$rest")
}
I will likely be running into many domains longer than 17 characters long. To
protect myself from a single space, I can use awk and 2 spaces as a delimiter:

--- xendomains.old      2008-05-28 14:13:21.000000000 -0600
+++ xendomains.new.2    2008-05-28 14:49:06.000000000 -0600
@@ -175,9 +175,8 @@

 parseln()
 {
-    name=`echo "$1" | cut -c0-17`
-    name=${name%% *}
-    rest=`echo "$1" | cut -c18- `
+    name=`echo "$1" | awk -F '  ' '{print$1}'`
+    rest=`echo "$1" | awk -F '  ' '{$1=""; print $0}' `
     read id mem cpu vcpu state tm < <(echo "$rest")
 }

I'm hoping there's a better solution for this though.


-- 
Configure bugmail: 
http://bugzilla.xensource.com/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

_______________________________________________
Xen-bugs mailing list
Xen-bugs@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-bugs

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-bugs] [Bug 1266] New: xendomains init.d script using cut, bugzilla-daemon <=