Changeset 1205 for bin

Show
Ignore:
Timestamp:
09/01/09 00:40:39 (6 months ago)
Author:
vasi
Message:

sshjour: Deal with bonjour-only hosts, without another hostname option
appFormat: Allow finding old apps

Location:
bin
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • bin/appFormat.pl

    r1170 r1205  
    77 
    88use File::Find; 
     9use Getopt::Long; 
     10use Pod::Usage; 
    911 
    1012sub machCPU { 
     
    3739        read($df, my $data, 20) == 20 or return; 
    3840        my $cpu = unpack($tmpl, substr($data, 0, 4)); 
    39         push @types, machCPU($cpu); 
     41        my $cpudesc = machCPU($cpu); 
     42        push @types, $cpudesc if $cpudesc; 
    4043    } 
    4144    return @types; 
     
    7477    } 
    7578    close $df; 
     79    return undef unless @types; 
    7680     
    7781    my %exec = (types => \@types, 
     
    133137} 
    134138 
     139# New apps should include Mach-O x86 or Mach-O AMD64 
     140sub newExecType { 
     141    my $exec = shift; 
     142    my %okcpu = map { $_ => 1 } qw(x86 AMD64);  
     143    return grep { $_->{format} eq 'Mach-O' && $okcpu{$_->{cpu}} } @{$exec->{types}}; 
     144} 
     145 
    135146sub dumpObj { 
    136147    my $exec = shift; 
     
    160171} 
    161172 
    162 sub findApps { 
     173sub findPred { 
     174    my $pred = shift; 
    163175    find(sub { 
    164176        return unless -f; 
    165177        my $exec = executableType($_) or return; 
     178        return unless $pred->($exec); 
    166179        print "$File::Find::name\n"; 
    167180        dumpObj($exec, "   "); 
     
    169182} 
    170183 
    171 findApps(@ARGV); 
     184=head1 NAME 
     185 
     186  appFormat.pl - Find the format of Mac apps 
     187   
     188=head1 SYNOPSIS 
     189 
     190  appFormat.pl [options] [path ...] 
     191   
     192  Options: 
     193    -o, --old       Find only old apps 
     194    -h, --help      Print this message 
     195 
     196=cut 
     197 
     198my $pred = sub { 1 }; # TRUE 
     199my $help = 0; 
     200GetOptions( 
     201    'old' => sub { $pred = sub { !newExecType(@_) } }, 
     202    'help' => \$help) or pod2usage(2); 
     203pod2usage(1) if $help; 
     204 
     205my @search = @ARGV ? @ARGV : ('.'); 
     206findPred($pred, @search); 
  • bin/sshjour

    r1195 r1205  
    1010end 
    1111 
     12unless found 
     13        STDERR.puts "Can't find host!" 
     14        exit 1 
     15end 
     16 
    1217exec('nc', found, fport || '22')