Created
April 1, 2010 08:06
-
-
Save naoyat/351544 to your computer and use it in GitHub Desktop.
unzip とか tar とかで、解凍するアーカイブファイルとしてURLを直接指定したい
This file contains hidden or 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 | |
# | |
# unzip とか tar とかで、解凍するアーカイブファイルとしてURLを直接指定したい | |
# | |
# $HOME/bin とかに unzip ないし tar という名前で保存し chmod +x しておく。 | |
# $HOME/bin を環境変数PATHの冒頭に指定すること | |
# | |
use strict; | |
use File::Basename; | |
my @cmd = ("/usr/bin/".basename($0)); | |
my $tmpdir = "/tmp"; | |
my @tmpfiles = (); | |
foreach (@ARGV) { | |
if (/\Ahttps?:\/\//) { | |
my $tmpfile = $tmpdir . "/" . basename($_); | |
system("rm -f $tmpfile"); | |
system("cd $tmpdir ; wget --quiet $_"); | |
push @cmd, $tmpfile; | |
push @tmpfiles, $tmpfile; | |
} else { | |
push @cmd, $_; | |
} | |
} | |
print "@cmd\n"; | |
system("@cmd"); | |
foreach (@tmpfiles) { | |
unlink; | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment