CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
why qx command won't store data in variable

 



regex2012
User

May 24, 2016, 10:02 AM

Post #1 of 4 (1678 views)
why qx command won't store data in variable Can't Post

I have part of a script that someone wrote that looks like this:


Code
foreach $line (@list) { 
#print "this is a line $line\n";
my @bpimageid = qx(/usr/openv/netbackup/bin/admincmd/bpimagelist -policy "${line}" -sl MONTHLY-Full -d $final_start -e $final_end -L |grep -i "backup id:" |awk '{print $3}');
print "This is the bpimageid @bpimageid\n";

foreach my $image (@bpimageid) {
my @fields = split ' ', $image;
print "these are the fileds @fields\n";
my @imageid = "@fields[2]\n";
my @fields = split '_', $image;
my @timelist = "@fields[1]";
foreach my $epoch (@timelist) {
my $date = strftime '%m/%d/%Y %H:%M:%S', localtime $epoch;
print "Here is the date $date\n";
my @fields = split ' ', $date;
print "Here is the image $image";
my $bpf = qx(/usr/openv/netbackup/bin/admincmd/bpflist -backupid "${image}" -d "${date}" -rl 2 -l);
print "this is the bpf $bpf\n";
open my $fh6, '>>', '/tmp/completed.txt' or die "unalbe to open file 'file' for writing: $!";
my @fields = split ' ', $bpf;
s/\/$/,/g for @fields;
print $fh6 "@fields[27,6]\n";
}
}
}
}

It runs just fine on one system but doesn't work on the other system.
the command it does not work with is

Code
my $bpf = qx(/usr/openv/netbackup/bin/admincmd/bpflist -backupid "${image}" -d "${date}" -rl 2 -l);


It does not return any output for the data stored in bpf. for the command that prints $bpf, nothing returns. However, both systems are Solaris 10.
I know the command works on both systems without being in a script because I ran it with data for image and date instead of variables.

The script runs perfectly on 5 systems, but on one it fails because it does not place the output of usr/openv/netbackup/bin/admincmd/bpflist -backupid "${image}" -d "${date}" -rl 2 -l into the variable $bpf.

Has anyone seen a similar issue? Just polling, I realize it would be hard to troubleshoot this without a lot more information. I'm running print commands to see if I can find anything further.


Laurent_R
Veteran / Moderator

May 24, 2016, 1:57 PM

Post #2 of 4 (1675 views)
Re: [regex2012] why qx command won't store data in variable [In reply to] Can't Post

It is rather unlikely to be a Perl problem. Have you tried to run the same commands at the command line of the various systems and observe the result?


BillKSmith
Veteran

May 24, 2016, 2:34 PM

Post #3 of 4 (1673 views)
Re: [regex2012] why qx command won't store data in variable [In reply to] Can't Post

I had a similar problem decades ago. A system engineer, much smarter than I, modified my program to run on all the machines by adding a small delay. A few years (yes, years) later, he found and corrected the hardware fault in the offending machine. Subtle hardware failures are extremely rare, but they can happen!
Good Luck,
Bill


regex2012
User

May 25, 2016, 7:06 AM

Post #4 of 4 (1666 views)
Re: [BillKSmith] why qx command won't store data in variable [In reply to] Can't Post

Thanks for all your replies! I am going to try the command on another system with the same exact o/s version and software version and see if there are any issues. We recently upgraded the machine - maybe during the upgrade something odd happened.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives