#! /bin/sh # This is the LHEA perl script: /cvmfs/extras-fp7.egi.eu/extras/heasoft/ftools/x86_64-unknown-linux-gnu-libc2.19-0/bin/fapropos # The purpose of this special block is to make this script work with # the user's local perl, regardless of where that perl is installed. # The variable LHEAPERL is set by the initialization script to # point to the local perl installation. #------------------------------------------------------------------------------- eval ' if [ "x$LHEAPERL" = x ]; then echo "Please run standard LHEA initialization before attempting to run /cvmfs/extras-fp7.egi.eu/extras/heasoft/ftools/x86_64-unknown-linux-gnu-libc2.19-0/bin/fapropos." exit 3 elif [ "$LHEAPERL" = noperl ]; then echo "During LHEA initialization, no acceptable version of Perl was found." echo "Cannot execute script /cvmfs/extras-fp7.egi.eu/extras/heasoft/ftools/x86_64-unknown-linux-gnu-libc2.19-0/bin/fapropos." exit 3 elif [ `$LHEAPERL -v < /dev/null 2> /dev/null | grep -ic "perl"` -eq 0 ]; then echo "LHEAPERL variable does not point to a usable perl." exit 3 else # Force Perl into 32-bit mode (to match the binaries) if necessary: if [ "x$HD_BUILD_ARCH_32_BIT" = xyes ]; then if [ `$LHEAPERL -V 2> /dev/null | grep -ic "USE_64_BIT"` -ne 0 ]; then VERSIONER_PERL_PREFER_32_BIT=yes export VERSIONER_PERL_PREFER_32_BIT fi fi exec $LHEAPERL -x $0 ${1+"$@"} fi ' if(0); # Do not delete anything above this comment from an installed LHEA script! #------------------------------------------------------------------------------- #!/usr/local/bin/perl # # fapropos -- # # This program takes a search string, and searches the FTools help # directory to find the names of tasks that mention that word. # # # $Id: fapropos,v 3.7 2013/01/24 21:41:28 irby Exp $ # # Jim Ingham # # Are we on VMS? if ($ENV{'HOME'} =~ /\$.*:\[.*\]|\[.*\]/) { $VMS = 1; push(@INC,"/ftools/bin_perl/"); # print "We are on VMS\n"; } else { $VMS = 0; push(@INC,"$ENV{FTOOLS}/scripts"); # print "We are on UNIX\n"; } require "utils.pl"; use Getopt::Std; getopts('behlpsw'); if ( defined $opt_h ) { print<; chop $keyword; if (defined $opt_p ) { } elsif (defined $opt_w) { $keyword =~ s/ +/\\b|\\b/g; $keyword = '\b'.$keyword.'\b'; } else { $keyword =~ s/ +/|/g; } } else { if ( defined $opt_p ) { $keyword = join("",@ARGV); } elsif ( defined $opt_w ) { $keyword = join('\b|\b',@ARGV); $keyword = '\b'.$keyword.'\b'; } else { $keyword = join("|",@ARGV); } } if ( defined $opt_e ) { print "Looking for: $keyword\n"; } if ( $VMS ) { $helpDir = "/ftools/help/"; } else { $helpDir = "$ENV{LHEA_HELP}"; } $workDir = pwd; chdir $helpDir || die "Cannot change directory to $helpDir\n"; opendir(DIR,".")|| die "Cannot read directory $helpDir\n"; @files = grep(/.*\.txt/,readdir(DIR)); @files = grep(!/ftools.txt/,@files); closedir(DIR); #print "Looking for keyword $keyword\n"; if (defined $opt_s ) { if ( ! defined $opt_b ) { foreach $FILE (@files) { open(FILE) || die "Cannot open file $FILE\n"; while ( ) { if ( /$keyword/o ) { ($topic = $FILE ) =~ s/\.txt$//; push(@goodTopics,$topic); last; } } } close(FILE); } else { foreach $FILE (@files) { open(FILE) || die "Cannot open file $FILE\n"; while ( ) { last if ( /^USAGE/ ); if ( /$keyword/o ) { ($topic = $FILE ) =~ s/\.txt$//; push(@goodTopics,$topic); last; } } } close(FILE); } } else { if ( ! defined $opt_b ) { foreach $FILE (@files) { open(FILE) || die "Cannot open file $FILE\n"; while ( ) { if ( /$keyword/oi ) { ($topic = $FILE ) =~ s/\.txt$//; push(@goodTopics,$topic); last; } } } close(FILE); } else { foreach $FILE (@files) { open(FILE) || die "Cannot open file $FILE\n"; while ( ) { last if (/^USAGE/); if ( /$keyword/oi ) { ($topic = $FILE ) =~ s/\.txt$//; push(@goodTopics,$topic); last; } } } close(FILE); } } if ( $#goodTopics == -1 ) { die "No matches found\n"; } else { if ( defined $opt_l ) { print join("\n",@goodTopics),"\n"; exit 0; } open(FTOOLS,"ftools.txt")|| die "Cannot open FTools generic help file index\n"; @ftools = ; close FTOOLS; $foundOne = 0; $#sub = -1; foreach $line (@ftools) { if ( $line =~ /^\s*$/ ) { $foundOne = 0; } elsif ( $line =~ /^\s*(\w+) -/ ) { $topic = $1; $foundOne = 0; foreach $goodTopic (@goodTopics) { if ( $goodTopic eq $topic ) { push(@sub,$line); $foundOne = 1; last; } } } elsif ( $line =~ /^\s/ ) { if ( $foundOne ) { push(@sub,$line); } } else { if ( $#sub > -1 ) { push(@output,"\n$subHeading\n",@sub); $#sub = -1; } $subHeading = $line; } } print @output; }