| 1 |
#!/usr/bin/perl -w |
| 2 |
# |
| 3 |
# ecaccess-file-dir: List ECaccess Directory Contents |
| 4 |
# |
| 5 |
# [email protected] - 2010-10-15 |
| 6 |
|
| 7 |
use ECMWF::ECaccess; |
| 8 |
use Getopt::Long; |
| 9 |
use Pod::Usage; |
| 10 |
use Term::ReadKey; |
| 11 |
|
| 12 |
my %opt = ( long => 0, version => 0, help => 0, manual => 0, retry => 0, debug => 0 ); |
| 13 |
|
| 14 |
pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if !GetOptions( |
| 15 |
\%opt, |
| 16 |
qw( |
| 17 |
long |
| 18 |
version |
| 19 |
help|? |
| 20 |
manual |
| 21 |
retry=i |
| 22 |
debug |
| 23 |
) |
| 24 |
); |
| 25 |
|
| 26 |
# Display version if requested |
| 27 |
die ECMWF::ECaccess->VERSION . "\n" if ( $opt{version} ); |
| 28 |
|
| 29 |
pod2usage( -noperldoc => 1, -exit => 1, verbose => 1 ) if ( $opt{help} ); |
| 30 |
pod2usage( -noperldoc => 1, -exit => 1, verbose => 2 ) if ( $opt{manual} ); |
| 31 |
|
| 32 |
my $ecaccessFile = $ARGV[0]; |
| 33 |
|
| 34 |
# If no file specified then list home directory |
| 35 |
$ecaccessFile = '' if ( not($ecaccessFile) ); |
| 36 |
|
| 37 |
# Create the ECaccess Controler |
| 38 |
my $ecaccess = ECMWF::ECaccess->new( $opt{retry}, $opt{debug}); |
| 39 |
|
| 40 |
# Get the Token (using the Certificate in $HOME) |
| 41 |
my $token = $ecaccess->getToken(); |
| 42 |
|
| 43 |
# Get the Control Channel |
| 44 |
my $controlChannel = $ecaccess->getControlChannel(); |
| 45 |
|
| 46 |
# List the files |
| 47 |
my $ecaccessFiles = $controlChannel->getDirList( $token, $ecaccessFile ); |
| 48 |
|
| 49 |
# Display the information for each file |
| 50 |
foreach my $ecaccessFile ( $ecaccessFiles->valueof('//getDirListResponse/return') ) { |
| 51 |
if ( $opt{long} ) { |
| 52 |
printf "%s 1 %-8s %-8s %-11s %s %s", $ecaccessFile->{permissions}, $ecaccessFile->{user}, $ecaccessFile->{group}, $ecaccessFile->{size}, |
| 53 |
$ecaccessFile->{time}, $ecaccessFile->{name}; |
| 54 |
print " -> " . $ecaccessFile->{link} if ( $ecaccessFile->{link} ); |
| 55 |
print "\n"; |
| 56 |
} |
| 57 |
else { |
| 58 |
print $ecaccessFile->{name} . "\n"; |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
# Logout |
| 63 |
END { |
| 64 |
$ecaccess->releaseToken($token) if ($token); |
| 65 |
} |
| 66 |
|
| 67 |
__END__ |
| 68 |
|
| 69 |
=head1 NAME |
| 70 |
|
| 71 |
ecaccess-file-dir - List ECaccess Directory Contents |
| 72 |
|
| 73 |
=head1 SYNOPSIS |
| 74 |
|
| 75 |
B<ecaccess-file-dir -version|-help|-manual> |
| 76 |
|
| 77 |
B<ecaccess-file-dir [-debug] [-long]> B<[>I<ecaccess-file>B<]> |
| 78 |
|
| 79 |
=head1 DESCRIPTION |
| 80 |
|
| 81 |
List information about I<ecaccess-file> (the $HOME directory by default). Sort entries alphabetically. |
| 82 |
|
| 83 |
The I<ecaccess-file> is in the form [domain:][/user-id/]path. Please read the "Shell commands -> File Management" |
| 84 |
section of the "ecaccess" guide for more information on the ECaccess File System. |
| 85 |
|
| 86 |
=head1 ARGUMENTS |
| 87 |
|
| 88 |
=over 8 |
| 89 |
|
| 90 |
=item I<ecaccess-file> (optional) |
| 91 |
|
| 92 |
The name of the ECaccess File/Directory to retrieve the details. |
| 93 |
|
| 94 |
=back |
| 95 |
|
| 96 |
=head1 OPTIONS |
| 97 |
|
| 98 |
=over 8 |
| 99 |
|
| 100 |
=item B<-long> |
| 101 |
|
| 102 |
Print detailed information about each file. |
| 103 |
|
| 104 |
=item B<-version> |
| 105 |
|
| 106 |
Display version number and exits. |
| 107 |
|
| 108 |
=item B<-help> |
| 109 |
|
| 110 |
Print a brief help message and exits. |
| 111 |
|
| 112 |
=item B<-manual> |
| 113 |
|
| 114 |
Prints the manual page and exits. |
| 115 |
|
| 116 |
=item B<-retry> I<count> |
| 117 |
|
| 118 |
Number of SSL connection retries per 5s to ECMWF. This parameter only apply to the |
| 119 |
initial SSL connection initiated by the command to the ECMWF server. It does not |
| 120 |
apply to all the subsequent requests made afteward as it is mainly targeting errors |
| 121 |
that can happen from time to time during the SSL handshake. Default is no retry. |
| 122 |
|
| 123 |
=item B<-debug> |
| 124 |
|
| 125 |
Display the SOAP and SSL messages exchanged. |
| 126 |
|
| 127 |
=back |
| 128 |
|
| 129 |
=head1 EXAMPLES |
| 130 |
|
| 131 |
B<ecaccess-file-dir> |
| 132 |
|
| 133 |
List information about each ECaccess File in the $HOME directory of the authenticated user. |
| 134 |
|
| 135 |
B<ecaccess-file-dir> I<home:/xyz/bin> |
| 136 |
|
| 137 |
List information about each ECaccess File in the $HOME/bin directory of the user xyz. |
| 138 |
|
| 139 |
B<ecaccess-file-dir> I<'home:/xyz/*.txt'> |
| 140 |
|
| 141 |
List information about each ECaccess File ending with ".txt" in the $HOME/bin directory |
| 142 |
of the user xyz. |
| 143 |
|
| 144 |
=head1 SEE ALSO |
| 145 |
|
| 146 |
B<ecaccess-file-delete>, B<ecaccess-file-get>, B<ecaccess-file-mget>, B<ecaccess-file-modtime>, B<ecaccess-file-mput>, |
| 147 |
B<ecaccess-file-rmdir>, B<ecaccess-file-copy>, B<ecaccess-file-chmod>, B<ecaccess-file-mdelete>, B<ecaccess-file-mkdir>, |
| 148 |
B<ecaccess-file-move>, B<ecaccess-file-put>, B<ecaccess-file-size> and B<ecaccess>. |
| 149 |
|
| 150 |
=cut |