Debian Codegraph @

script/ecaccess-file-chmod

raw
1 #!/usr/bin/perl -w
2 #
3 # ecaccess-file-chmod: Change ECaccess File Mode Bits
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 $mode = $ARGV[0];
28 my $ecaccessFile = $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 mode specified!\n" ) if not($mode);
33 pod2usage( -noperldoc => 1, -exit => 1, verbose => 0, -msg => "No ecaccess-file specified!\n" ) if not($ecaccessFile);
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 # Trigger the event
45 $controlChannel->changeFileMode( $token, $mode, $ecaccessFile );
46
47 # Logout
48 END {
49 $ecaccess->releaseToken($token) if ($token);
50 }
51
52 __END__
53
54 =head1 NAME
55
56 ecaccess-file-chmod - Change ECaccess File Mode Bits
57
58 =head1 SYNOPSIS
59
60 B<ecaccess-file-chmod -version|-help|-manual>
61
62 B<ecaccess-file-chmod [-debug]> I<mode> I<ecaccess-file>
63
64 =head1 DESCRIPTION
65
66 Allow changing the ECaccess File Mode Bits of the given I<ecaccess-file> according to I<mode>, which is an octal number
67 representing the bit pattern for the new mode bits.
68
69 The I<ecaccess-file> is in the form [domain:][/user-id/]path. Please read the "Shell commands -> File Management" section of
70 the "ecaccess" guide for more information on the ECaccess File System.
71
72 =head1 ARGUMENTS
73
74 =over 8
75
76 =item I<mode>
77
78 Octal number representing the bit pattern for the new mode bits (e.g. 0600).
79
80 =item I<ecaccess-file>
81
82 The name of the ECaccess File to change the File Mode Bits.
83
84 =back
85
86 =head1 OPTIONS
87
88 =over 8
89
90 =item B<-version>
91
92 Display version number and exits.
93
94 =item B<-help>
95
96 Print a brief help message and exits.
97
98 =item B<-manual>
99
100 Prints the manual page and exits.
101
102 =item B<-retry> I<count>
103
104 Number of SSL connection retries per 5s to ECMWF. This parameter only apply to the
105 initial SSL connection initiated by the command to the ECMWF server. It does not
106 apply to all the subsequent requests made afteward as it is mainly targeting errors
107 that can happen from time to time during the SSL handshake. Default is no retry.
108
109 =item B<-debug>
110
111 Display the SOAP and SSL messages exchanged.
112
113 =back
114
115 =head1 EXAMPLES
116
117 B<ecaccess-file-chmod> I<0700> I<ec:bin/a.out>
118
119 Change the File Mode Bits to Read and Write for owner and Read for everybody else on a File in the bin directory of the ECFS
120 directory of the authenticated user.
121
122 =head1 SEE ALSO
123
124 B<ecaccess-file-delete>, B<ecaccess-file-get>, B<ecaccess-file-mget>, B<ecaccess-file-modtime>, B<ecaccess-file-mput>,
125 B<ecaccess-file-rmdir>, B<ecaccess-file-copy>, B<ecaccess-file-dir>, B<ecaccess-file-mdelete>, B<ecaccess-file-mkdir>,
126 B<ecaccess-file-move>, B<ecaccess-file-put>, B<ecaccess-file-size> and B<ecaccess>.
127
128 =cut