I have the following code, I am trying to get the number of jobs returned to me in $server_num_jobs. But $server_num_jobs keeps returning 1. I have tried several variations on the code such as $server_num_jobs=`/usr/bin/lpstat -h $server -W not-completed |wc -l`; amongst others.
#!/usr/bin/perl -w
use strict;
use diagnostics;
use Data::Dumper;
snip ...
my @cups_num_jobs_cmd=("/usr/bin/lpstat ", "-h", $server, "-W not-comp
+leted");
print Dumper "cmd = @cups_num_jobs_cmd";
my @cups_num_jobs=system(@cups_num_jobs_cmd);
print Dumper "cups_jobs = @cups_num_jobs";
$server_num_jobs=scalar(@cups_num_jobs);
print Dumper "server_num = $server_num_jobs";
$server is the name of a cups server
I don't get any errors from the code, but what I am trying to do is to get the number of jobs back ie 3. If I run the command from the command line I get back three jobs as in the following:
R_NETADMIN_NB-46 root 15360 Wed 16 Mar 2005 01:05
+:25 PM EST
RSPARE_NB-47 root 15360 Wed 16 Mar 2005 01:05
+:33 PM EST
RSPARE_NB-48 root 15360 Wed 16 Mar 2005 01:05
+:38 PM EST
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.