/[cvs]/nfo/perl/scripts/shortcuts/cp_deep
ViewVC logotype

Annotation of /nfo/perl/scripts/shortcuts/cp_deep

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Tue Jan 28 11:03:30 2003 UTC (21 years, 5 months ago) by root
Branch: MAIN
+ initial commit - needed for home2web

1 root 1.1 #!/usr/bin/perl
2    
3     use strict;
4     use warnings;
5    
6    
7     my $debug = 0;
8    
9     use Data::Dumper;
10    
11     # read arguments from cli
12     my $settings = {};
13     my $args = [];
14     while (my $arg = shift) {
15     next if !$arg;
16     if ($arg =~ m/^--(.+?)$/) {
17     $settings->{$1} = 1;
18     next;
19     }
20     push @$args, $arg;
21     }
22    
23     # transfer arguments to settings
24     $settings->{target} = pop @$args;
25     $settings->{source} = $args;
26    
27     # debug
28     print Dumper($settings), "\n" if $debug;
29    
30     my $cp_arg = '';
31     $cp_arg .= '--symbolic-link ' if $settings->{symlink};
32     $cp_arg .= '--remove-destination ' if $settings->{force};
33    
34     # run it
35     foreach my $source (@{$settings->{source}}) {
36    
37     $source =~ s/\(/\\(/g;
38     $source =~ s/\)/\\)/g;
39     $source =~ s/\s/\\ /g;
40    
41     print "linking $source", "\n";
42    
43     my $cmd = <<EOC;
44     mkdir -p $settings->{target} && \
45     cd $settings->{target} && \
46     cp $cp_arg $source .
47     EOC
48    
49     #print "cmd: $cmd", "\n";
50     #print `$cmd`, "\n";
51    
52     #`$cmd`;
53     system($cmd);
54    
55     }
56    
57     1;
58    

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed