Debian Codegraph @

script/ecaccess-file-copy

raw
1 #!/usr/bin/perl -w
2 #
3 # ecaccess-file-copy: Copy an ECaccess File
4 #
5 # [email protected] - 2010-10-15
6
7 use ECMWF::ECaccess;
8 use Getopt::Long;
9 use Pod::Usage;
10
11 my %opt = ( version => 0, erase => 0, help => 0, manual => 0, retry => 0, debug => 0 );
12
13 pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if !GetOptions(
14 \%opt,
15 qw(
16 erase
17 version
18 help|?
19 manual
20 retry=i
21 debug
22 )
23 );
24
25 # Display version if requested
26 die ECMWF::ECaccess->VERSION . "\n" if ( $opt{version} );
27
28 my $sourceECaccessFile = $ARGV[0];
29 my $targetECaccessFile = $ARGV[1];
30
31 pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if ( $opt{help} );
32 pod2usage( -noperldoc => 1, -exit => 1, verbose => 2 ) if ( $opt{manual} );
33 pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "No source-ecaccess-file specified!\n" ) if not($sourceECaccessFile);
34 pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "No target-ecaccess-file specified!\n" ) if not($targetECaccessFile);
35
36 # Create the ECaccess Controler
37 my $ecaccess = ECMWF::ECaccess->new( $opt{retry}, $opt{debug});
38
39 # Get the Token (using the Certificate in $HOME)
40 my $token = $ecaccess->getToken();
41
42 # Get the Control Channel
43 my $controlChannel = $ecaccess->getControlChannel();
44
45 # Copy the file
46 $controlChannel->copyFile( $token, $sourceECaccessFile, $targetECaccessFile, SOAP::Data->type( boolean => $opt{erase} ) );
47
48 # Logout
49 END {
50 $ecaccess->releaseToken($token) if ($token);
51 }
52
53 __END__
54
55 =head1 NAME
56
57 ecaccess-file-copy - Copy an ECaccess File
58
59 =head1 SYNOPSIS
60
61 B<ecaccess-file-copy -version|-help|-manual>
62
63 B<ecaccess-file-copy [-debug] [-erase]> I<source-ecaccess-file> I<target-ecaccess-file>
64
65 =head1 DESCRIPTION
66
67 Copy the I<source-ecaccess-file> to the I<target-ecaccess-file>.
68
69 The I<source-ecaccess-file> and I<target-ecaccess-file> are in the form [domain:][/user-id/]path. Please
70 read the "Shell commands -> File Management" section of the "ecaccess" guide for more information on the
71 ECaccess File System.
72
73 =head1 ARGUMENTS
74
75 =over 8
76
77 =item I<source-ecaccess-file>
78
79 The source ECaccess File name for the copy.
80
81 =item I<target-ecaccess-file>
82
83 the target ECaccess File name for the copy.
84
85 =back
86
87 =head1 OPTIONS
88
89 =over 8
90
91 =item B<-erase>
92
93 Delete the source file once the copy has completed successfully. By default the source file is not deleted.
94
95 =item B<-version>
96
97 Display version number and exits.
98
99 =item B<-help>
100
101 Print a brief help message and exits.
102
103 =item B<-manual>
104
105 Prints the manual page and exits.
106
107 =item B<-retry> I<count>
108
109 Number of SSL connection retries per 5s to ECMWF. This parameter only apply to the
110 initial SSL connection initiated by the command to the ECMWF server. It does not
111 apply to all the subsequent requests made afteward as it is mainly targeting errors
112 that can happen from time to time during the SSL handshake. Default is no retry.
113
114 =item B<-debug>
115
116 Display the SOAP and SSL messages exchanged.
117
118 =back
119
120 =head1 EXAMPLES
121
122 B<ecaccess-file-copy> I<ec:bin/a.out> I<c1a:/c1a/tmp/systems/xyz/a.out>
123
124 Copy the I<a.out> File in the ECFS bin directory of the authenticated user to the "/c1a/tmp/systems/xyz" directory on c1a.
125
126 =head1 SEE ALSO
127
128 B<ecaccess-file-delete>, B<ecaccess-file-get>, B<ecaccess-file-mget>, B<ecaccess-file-modtime>, B<ecaccess-file-mput>,
129 B<ecaccess-file-rmdir>, B<ecaccess-file-chmod>, B<ecaccess-file-dir>, B<ecaccess-file-mdelete>, B<ecaccess-file-mkdir>,
130 B<ecaccess-file-move>, B<ecaccess-file-put>, B<ecaccess-file-size> and B<ecaccess>.
131
132 =cut