Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-04-2011, 08:03 AM   #1
Registered: Mar 2005
Distribution: Ubuntu 12.04 LTS
Posts: 249

Rep: Reputation: 16
rpm doesn't work when used with URL that's redirected

If I do the following, if the URL is a redirect, it doesn't work

rpm -ivh http://path/to/rpm

I have to use wget http://path/to/rpm which resolves the redirect and downloads the file, then run rpm on that file.

More for my knowledge of bash than anything else, would there be a way to redirect the file downloaded from wget into the rpm (something like redirection or pipes or something), so that they could be combined into one command and you wouldn't explicitly save the file first.

Something like... rpm -ivh << wget http://path/to/rpm
(I'm still a relative newbie so pardon my ignorance)

I have one more question, and that is whether there is a command in linux, such as wget, that would let me pass it a URL and output the redirected-to URL if the argument.

e.g. ('wget --someflag http://orig/url' would output 'http://url-after-redirects-followed')
Old 06-04-2011, 08:13 AM   #2
Shahnawaz Uqaili
Registered: May 2011
Location: Karachi, Sindh Pakistan
Distribution: RHEL, CentOS, Debian/Ubuntu, Microsoft Windows
Posts: 46

Rep: Reputation: Disabled
What you want to install from URL?

If you are using wget

Then it will download that package in your home directory.
Old 06-05-2011, 06:08 AM   #3
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 & 7
Posts: 3,296

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Redirection is done by a browser based on the response to the GET for the page.
Here's some perl code off the net to do redirect using the LWP::UserAgent
module, which by default will follow up to 7 levels of redirection (you can
increase that if you feel the need).

# by Tony Miller
use strict;
use warnings;

use LWP::UserAgent;

my $ua;  # Instance of LWP::UserAgent
my $url = $ARGV[0] || die "Usage: <url>\n";
my $req; # Instance of (original) request
my $res; # Instance of HTTP::Response returned via request method

$ua = LWP::UserAgent->new;
$ua->agent("$0/0.1 " . $ua->agent);

$req = HTTP::Request->new(HEAD => $url);
$req->header('Accept' => 'text/html');

$res = $ua->request($req) || die "Request failed for $url\n";;

if ($res->is_success) {
    print "Final URL = " . $res->request->url() . "\n";
} else {
    print "Error: " . $res->status_line . "\n";
example of use:
perl ''
Final URL =


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] wget passing URL parameters doesn't seem to work nonshatter Linux - Software 3 10-04-2010 07:48 AM
Firefox Specific Refresh Problem. Ffox Can't remember redirected URL after ajax call supertramp Programming 2 07-20-2009 07:33 AM
rpm -i --prefix=/home/user package.src.rpm doesn't work? registering Linux - Software 2 07-18-2007 11:28 AM
rpm -e doesn't work for me! Freestone Linux - Newbie 5 03-31-2006 07:43 PM
url encoding doesn't work fine with PHP markus1982 Programming 0 08-30-2003 02:04 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:28 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration