Created
December 24, 2011 04:48
-
-
Save lojikil/1516330 to your computer and use it in GitHub Desktop.
It is a long story, but I needed a quick and dirty wget-clone, enough to support `apt-cyg`, the Cygwin package downloader. one man page & 5 minutes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# poor person's wget; enough to satisfy apt-cyg at least. | |
# works well enough to download OCaml via apt-cyg, so that's | |
# good enough for me. | |
use strict; | |
use LWP::Simple; | |
my($opt,$dest,$file,$rc); | |
if(scalar(@ARGV) == 2) { | |
$opt = shift(@ARGV); | |
$dest = shift(@ARGV); | |
} else { | |
$dest = shift(@ARGV) or die "Usage: muwget [opt] url"; | |
} | |
$file = $dest; | |
$file =~ s/.*\/(.*?)$/$1/; | |
if(defined $opt and $opt eq "-nc") { | |
if(-f $file) { | |
print "file exists & -nc specified"; | |
exit 0; | |
} | |
} | |
$rc = getstore($dest,$file); | |
if($rc != 200) { | |
exit 1; | |
} else { | |
exit 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment