Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

We habe a password protected Bugzilla instance and I would like to download a report in CSV form.

Using

wget $URL

or

curl $URL

I do not get any error, no authentication request. Bugzilla just delivers a 0 bytes file

The same happens with a browser. If I type the URL in I get the empty file. If I log in on any Bugzilla page before than the Bugilla will deliver the file.

Is there a way to authenticate from the command line, store the cookie and then fetch the report using the same cookies?

share|improve this question
    
Just use the built-in Tabular reports to do this. This question would be best directed towards the Bugzilla community as it might require a modification to Bugzilla itself. Since Bugzilla is server software I doubt this is actually an on topic question. – Ramhound Aug 8 '13 at 11:52
    
I am using the tabular reports. But I access the URL I get no way to log in. Bugzilla is requesting authentication only for HTML pages but not for downloads. It just gives you an empty file. I wanted to know it there is a way to get them from the user side. I have no means to change anything on the server. – Matteo Aug 8 '13 at 12:12
    
If you don't have the means to change the server to resolve the problem then you are out of luck. – Ramhound Aug 8 '13 at 12:15
    
Why? I am now writing a small script with Perl and Mechanize: fetch a page, submit credentials, store cookie, access the table. I asked since what I am doing seems an overkill and maybe there is something I missed (that does not need scripting). I still don't get the down vote but whatever not a big issue – Matteo Aug 8 '13 at 12:19
up vote 0 down vote accepted

Ok maybe there are better solutions but it can be done with a little Perl script

#!/usr/bin/perl

use strict;
use warnings;

use WWW::Mechanize;
use Readonly;

Readonly::Scalar my $base_url => 'https://example.org';
Readonly::Scalar my $url      => "$base_url/bugzilla/report.cgi?...&ctype=csv&format=table";

# just as an example: put them in a property file
Readonly::Scalar my $username => 'USERNAME';
Readonly::Scalar my $password => 'PASSWORD';

my $mech = WWW::Mechanize->new();

$mech->get("$url&GoAheadAndLogIn=1");

my %login = (
    "Bugzilla_login"=> $username,
    "Bugzilla_password"=> $password
);
$mech->set_fields(%login);
$mech->submit( 'GoAheadAndLogIn' );
$mech->get( $url );
$mech->save_content( 'name.csv' );

1;
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .