Macslayer has asked for the wisdom of the Perl Monks concerning the following question:
The problem is, I can't get any info under the <job_list> tag, such as <slots>. No matter what I do, the Perl script will return nothing. Here's the code I'm using:<?xml version='1.0'?> <job_info ... ?revision=1.11"> <queue_info> <Queue-List> <name>long_zeta@zeta09.local</name> <qtype>BIP</qtype> <slots_used>1</slots_used> <slots_resv>0</slots_resv> <slots_total>8</slots_total> <arch>lx26-amd64</arch> <resource name="arch" type="hl">lx26-amd64</resource> <resource name="num_proc" type="hl">8</resource> ... <job_list state="running"> <JB_job_number>642412</JB_job_number> <JAT_prio>5.00248</JAT_prio> <JAT_ntix>0.00002</JAT_ntix> <JB_name>U6s53097</JB_name> <JB_owner>npatel37</JB_owner> <JB_project>correlat</JB_project> <JB_department>defaultdepartment</JB_department> <state>r</state> <cpu_usage>224919.00000</cpu_usage> <mem_usage>15753.53518</mem_usage> <io_usage>0.32690</io_usage> <tickets>0</tickets> <JB_override_tickets>0</JB_override_tickets> <JB_jobshare>0</JB_jobshare> <otickets>0</otickets> <ftickets>0</ftickets> <stickets>0</stickets> <JAT_share>0.00002</JAT_share> <slots>1</slots> </job_list> </Queue-List> </queue_info> </job_info>
That script won't print out anything. I've used Data::Dumper and Data::Dump; both printed out the tree exactly as expected, without the <job_list> tag anywhere to be found. I also should point out that, in between the <queue-info> tags, there are many many <Queue-List> tags that may or may not contain a <job_list>. Some have two or three, others have none. However, even Data::Dumper cannot find those, even when I grep for them. Thanks, Ben Olsonuse XML::Smart; my ($xml,$qstat); $qstat=`qstat -u \* -ext -xml -s r -F`; $xml = XML::Smart->new($qstat); foreach ($xml->{job_info}->{queue_info}->{"Queue-List"}('@') ) { print $_->{job_list}->{slots}; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing XML output from `qstat`
by kcott (Archbishop) on May 05, 2014 at 08:12 UTC | |
by Macslayer (Initiate) on May 05, 2014 at 18:05 UTC | |
|
Re: Parsing XML output from `qstat`
by Anonymous Monk on May 05, 2014 at 08:46 UTC | |
by Macslayer (Initiate) on May 05, 2014 at 18:04 UTC | |
by Anonymous Monk on May 05, 2014 at 23:29 UTC | |
by Macslayer (Initiate) on May 06, 2014 at 16:58 UTC |