Debian Codegraph @

script/ecaccess-file-move

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