ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to write a script to clean up my RH Satellite repositories so I can get rid of a lot of the old rpm's that are taking up space.
Most of the API's that I've been looking up are functioning as I would expect. However, some are not.
For example, I'm trying to identify what channel a package is in. There is an API called listProvidingChannels that seems like it might be useful, but when I use it, I can't seem to get any useful information out of it.
I've got an open session set up in the code already and I run the following line:
Quote:
my $channels = $client->call('packages.listProvidingChannels', $session, $packageid);
When I try to get information out of $channels, however, I can't get anything useful.
Any reference to $channels->{'name'} gives me the following errors:
Quote:
Pseudo-hashes are deprecated at ./cleansat.pl line 53, <> line 4.
Argument "\x{52}\x{65}..." isn't numeric in hash element at ./cleansat.pl line 53, <> line 4.
Bad index while coercing array into hash at ./cleansat.pl line 53, <> line 4.
If I simply do:
Quote:
print "$channels\n";
I get
Quote:
ARRAY(0x94ae35c)
Not sure where to find more information about these API's (this one specifically). Other API's that I use the same type of syntax for work as one would expect. For example, I have a line:
Quote:
my $latestpackages = $client->call('channel.software.listLatestPackages', $session, $chan);
If I reference $latestpackages->{'name'}, I get "acl" for example. If I reference $latestpackages->{'id'}, I get "54079" and so on.
Does anyone know more about this? Or know where I can find better, more detailed information?
The syntax that Data::Dumper uses in its output will give you some hints about how to use the data structure - although I don't use Red Hat myself, if you paste the output here I might be able to give you a push in the right direction
I added a Dumper call with one of the other similar calls (the listLatestPackages one mentioned earlier) and the structure seems pretty much exactly the same...just different entries..but same format.
The one below is the one that's failing.
Quote:
$VAR1 = [
{
'parent_label' => ' ',
'name' => 'Red Hat Enterprise Linux Server (v. 6 for 64-bit x86_64)',
'label' => 'rhel-x86_64-server-6'
}
];
Pseudo-hashes are deprecated at ./cleansat.pl line 59, <> line 4.
Argument "\x{72}\x{68}..." isn't numeric in hash element at ./cleansat.pl line 59, <> line 4.
Bad index while coercing array into hash at ./cleansat.pl line 59, <> line 4.
Okay, the data structure you dumped is an arrayref ([]) of hashrefs ({}), so I assume it represents a list of available channels (I don't know any RHEL-specific terminology so I'm not sure what a "channel" really is). You can iterate over the arrayref in the usual way, but remember to dereference the arrayref before operating on it as if it were an array:
Code:
foreach my $channel (@{$channels}) {
print $channel->{name}, "\n";
}
That's pretty much exactly the code I have...before removing anything I wanted to just print out each element to verify I was getting the right information. That exact code that you have there is what throws the errors I put in the original post. That's why I'm so confused about this. It seems like that should work. But it's not. :-(
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.