Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env perl
- # devilzc0de.org (c) 2012
- use File::Basename;
- use File::Copy;
- if(($#ARGV != 0) && ($#ARGV != 1)){
- print "usage : perl ".basename($0)." [path to dir/file] [path to save file]\r\n";
- print "ex : perl ".basename($0)." /etc\r\n";
- print "ex : perl ".basename($0)." /etc/issue\r\n";
- print "ex : perl ".basename($0)." /etc/issue issue_new_copy\r\n";
- exit;
- }
- $target = @ARGV[0];
- $target =~ s/\\/\//g;
- if(-d $target){
- if(!($target =~ /.*\/+$/)){
- $target = $target."/";
- }
- if(opendir(DIR,$target)){
- while($file = readdir(DIR)){
- if(($file eq ".") || ($file eq "..")){ next; }
- $fs = "";
- if(-d $target.$file){
- $fs = "[ DIR ]";
- }
- elsif(-f $target.$file){
- $fs = (-s $target.$file);
- }
- print sprintf("%12s", $fs)." ".$file."\r\n";
- }
- closedir(DIR);
- }
- }
- elsif(-f $target){
- if($#ARGV == 1){
- copy($target, @ARGV[1]);
- }
- else{
- if(open(FILE,$target)){
- binmode FILE;
- while (($n = read FILE, $data, 1024) != 0) {
- print $data;
- }
- close(FILE);
- }
- }
- }
- else{
- print "Can't found file or folder : ".$target;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement