File: //scripts.20110531.215904.25158/cpfetch
#!/usr/bin/perl
# cpanel - cpfetch Copyright(c) 2010 cPanel, Inc.
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited
BEGIN { unshift @INC, '/usr/local/cpanel'; }
use Cpanel::HttpRequest ();
$| = 1;
my $httpClient = Cpanel::HttpRequest->new( 'hideOutput' => 0 );
my $url = $ARGV[0];
if ( !$url ) {
die 'No file specified';
}
elsif ( $url !~ /^http/ ) {
$url = 'http://httpupdate.cpanel.net/' . $url;
}
my $file;
if ( !defined $ARGV[1] || $ARGV[1] eq '' ) {
my @FILE = split( /\//, $url );
$file = pop(@FILE);
}
else {
$file = $ARGV[1];
}
if ( !-e $file ) {
$httpClient->download( $url, $file );
}
if ( !-e $file ) {
die "Unable to fetch file $file.";
}
exit 1;