FireyIce01 has asked for the wisdom of the Perl Monks concerning the following question:

I'm working on a script that searches for files on a diskfarm. The problem is that not all the files are on the diskfarm, and some of them are located on one or 5 processing machines... 3 of these machines I can telnet into, the other 2 require SSH. We don't have net::SSH or net::SSH:perl installed, nor do I have the pull to get the System Admins to install the module (I'm writing this tool to help myself and the other 4 operators that work in frontend so that we don't have to manually go out and find the files) My question is, is there any compatibility so that I can take the script I've got working on one system to be able to SSH into the other systems and check them for the files, or will I need to have a copy of the program running on each system? Below is the code that I have thus far...
#!/usr/bin/perl use strict; use File::stat; use Date::Manip; # This is a program that is intended to allow FEP operators # a tool that will facilitate in monitoring incoming transmissions # and preprocessor logs. #------------------- Define Subroutines ------------------# # # # Main is a subroutine simply written for flow control sub Main { my $corp = $_[0]; print "Logs:\n"; farmInput($corp, 'farm/*/*/log/'); print "Input:\n"; farmInput($corp,'farm/*/*/input/'); print "Save:\n"; farmInput($corp, 'farm/*/*/input/save/'); print "Failed:\n"; farmInput($corp, 'farm/*/*/input/failed/'); } # end Main # This subroutine takes 2 input variables, the corp (or any text you w +ant to find) # and the path in which to search (with /usr/local/ being the root of +the search) sub farmInput { my($corp, $finalPath) = ($_[0], $_[1]); my $path = "/usr/local/$finalPath*$corp*"; my @farms = glob($path); foreach my $farm (@farms) { my $s = stat($farm); printf "%s\nAge[%s] size[%s]\n", $farm, ParseDateString("epoch".$s +->mtime()), $s->size(); # the above line does the same thing as the next 4 commented lines # printf "%s: Age [%s], size[%s]\n", # $farm, # DateCalc( "Jan 1, 1970 00:00:00 GMT",$s->mtime() ), # $s->size(); } # end of foreach statement } # end farmInput #------------------- End Subroutines ---------------------# print "What corp are you looking for? " ; chomp(my $whatWeWant = <STDIN>); Main($whatWeWant);

Replies are listed 'Best First'.
Re: SSH compatibility without external modules?
by sasikumar (Monk) on Jan 18, 2005 at 10:31 UTC
Re: SSH compatibility without external modules?
by simonm (Vicar) on Jan 18, 2005 at 17:51 UTC
    We don't have net::SSH or net::SSH:perl installed...

    The other way that ssh is often automated is via the Expect module, which you should be able to install without admin permissions, because it's pure Perl.

    is there any compatibility so that I can take the script I've got working on one system to be able to SSH into the other systems and check them for the files, or will I need to have a copy of the program running on each system?

    The question is a bit vague -- there are a number of ways you could tackle this and we don't have enough information to decide which is the best for your context.

    My suggestion would be to copy this script to all of the relevant machines, and then write a separate wrapper script which could be placed on your "home" machine and which then ssh/telnets into each host and runs the script with the current arguments. (If they all supported SSH, this would be pretty easy, because you can pass the command name to the ssh binary: "ssh user@hostname farm_find.pl corpname".)

Re: SSH compatibility without external modules?
by hostyle (Scribe) on Jan 18, 2005 at 22:38 UTC

    It depends on what you are trying to do. Have you looked at the ssh man page?

    ssh [user@]hostname [command]

    Note the command bit, where you could use the unix built-in find or a perl one-liner. All via perl's system()

      well, as you can see from the code above, what I'm doing is checking input/, input/save/, input/failed/ and log/ for any files matching *$corp* and printing them with their path, filesize, and last modified date to screen. We have a diskfarm at /usr/local/farm that is a NFS mapping on all 5 systems, but some of the older corps are on /usr/local/ on each of the individual systems... all I really want to do is have it SSH over to the other system, search the folders that aren't on the farm, and then print the results to the screen.