Changeset 28794 for branches/eam_branches/ipp-20100621/Nebulous/bin/neb-ls
- Timestamp:
- Jul 30, 2010, 9:31:50 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100621/Nebulous/bin/neb-ls
r24346 r28794 1 1 #!/usr/bin/env perl 2 2 3 # Copyright (C) 2007-2009 Joshua Hoblitt 3 # Copyright (C) 2007-2009 Joshua Hoblitt, 2010 Chris Waters 4 4 5 5 use strict; … … 16 16 my ( 17 17 $server, 18 $long, 19 # $recursive, 18 $path, 19 $ls, 20 $column, 20 21 ); 21 22 22 23 $server = $ENV{'NEB_SERVER'} unless $server; 23 24 24 # make --long the default25 $long = 1;26 25 27 26 GetOptions( 28 27 'server|s=s' => \$server, 29 # 'recursive|r' => \$recursive, 30 'l|1' => \$long, 28 'path|p' => \$path, 29 'l' => \$ls, 30 'column|c' => \$column, 31 31 ) || pod2usage( 2 ); 32 33 # twiddle column so that it does it by default. 34 35 $column = not $column; 32 36 33 37 my $pattern = shift; … … 47 51 $pattern ||= "/"; 48 52 49 #if ($recursive) { 50 # $pattern = "^" . $pattern . ".*"; 51 #} else { 52 # $pattern = "^" . $pattern . "\$"; 53 #} 53 my $keys = $neb->find_objects_wildcard($pattern); 54 54 55 my $keys = $neb->find_objects($pattern); 56 55 if ($path) { 56 my @files; 57 foreach my $key (@{ $keys }) { 58 my $uris = $neb->find_instances($key); 59 if (defined $uris) { 60 push @files, URI->new(@$uris[0])->file; 61 } 62 } 63 @{ $keys } = @files; 64 } 65 if ($ls) { 66 my @files; 67 foreach my $key (@{ $keys }) { 68 my $uris = `ls -al $key`; 69 chomp($uris); 70 if (defined $uris) { 71 push @files, $uris; 72 } 73 } 74 @{ $keys } = @files; 75 } 57 76 if ($keys) { 58 if ($long) { 59 print join("\n", @{ $keys }), "\n"; 60 } else { 61 print join(" ", @{ $keys }), "\n"; 77 if ($column) { 78 open(COLUMN,"|column") || die "Cannot open column command."; 79 print COLUMN join("\n", @{ $keys }), "\n"; 80 close(COLUMN); 81 } 82 else { 83 print join("\n", @{ $keys }), "\n"; 62 84 } 63 85 } 86 64 87 65 88 __END__ … … 73 96 =head1 SYNOPSIS 74 97 75 neb-ls [--server <URL>] [- l|-1] [--recursive] <pattern>98 neb-ls [--server <URL>] [-c] [-p] <pattern> 76 99 77 100 =head1 DESCRIPTION 78 101 79 102 This program list Nebulous keys matched by C<<pattern>>. Call it with no 80 arguments is equival anet to searching with the pattern C<.*>. Where81 C<<pattern>> is a POSIX 1003.2 compatable regular repression.103 arguments is equivalent to searching with the pattern C<neb://>. SQL like 104 wildcards are supported to select out certain files. 82 105 83 106 =head1 OPTIONS … … 85 108 =over 4 86 109 87 =item * - l|-1110 =item * --path|-p 88 111 89 Use a long listing format. 112 Find the disk files corresponding to the keys found. 113 114 =item * --column|-c 115 116 Disable column formatting, and output results one to a line. 90 117 91 118 Optional 92 119 93 =cut94 #=item * --recursive|-r95 #96 #By default C<neb-ls> will only try to match the exact string provided to it.97 #With this option set all keys which match C<<pattern>> as a REGEX or substring98 #will be returned.99 #100 #Optional101 #102 120 =item * --server|-s <URL> 103 121 … … 122 140 =back 123 141 124 =head1 CREDITS125 126 Just me, myself, and I.127 128 142 =head1 SUPPORT 129 143 … … 132 146 =head1 AUTHOR 133 147 134 Joshua Hoblitt <jhoblitt@cpan.org> 148 Joshua Hoblitt <jhoblitt@cpan.org>, Chris Waters 135 149 136 150 =head1 COPYRIGHT 137 151 138 Copyright (C) 2007-20 09 Joshua Hoblitt. All rights reserved.152 Copyright (C) 2007-2010 Joshua Hoblitt / Chris Waters. All rights reserved. 139 153 140 154 This program is free software; you can redistribute it and/or modify it under
Note:
See TracChangeset
for help on using the changeset viewer.
