[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-bugs] [Bug 1266] New: xendomains init.d script using cut
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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |