Your 'value added combination example'

Manning, Rob Rob_Manning at mail.ci.baltimore.md.us
Wed Nov 3 10:11:27 CST 1999


	-----Original Message-----
	From:	James W. Sandoz; (BIO;FAC) [SMTP:sandoz at umbc.edu]
	Sent:	Wednesday, November 03, 1999 8:47 AM
	To:	Rob Manning
	Subject:	Your 'value added combination example'

	Rob,
		A quicker way may be to use the -s filetest

	:foreach my $file(@files) {
		$filesize = -s $_;

	etc

		Just butting in...
		Jim

	Mr. James W. Sandoz, Instructor, UMBC Dept of Biol Sciences,  
					 1000 Hilltop Circle
					 Catonsville, MD 21250
	voice: (410) 455-3497; fax: 455-3875; net: sandoz at umbc.edu




Jim,

These filenames are the result of an 'ls' in a directory
on a remote machine, if you're talking about the array 
@files generated by these lines

my $t = Net::Telnet->new( Timeout => 10,Prompt => '/' . $shell_prompt .
'/' , Host => $host);
	
$t->login($user, $pass) or die "Login failed: @{[$t->errmsg() ]}\n";

my @files = $t->cmd('ls -l' . $filename);

If so then the -s file test operator should always return 
"undefined" for files that do not exist - the files in the 
@files do not exist on the machine that the perl script 
is executing on.  They only exist on the remote machine
and we happen to see them because we're using the 
'cmd' method to run the "ls -l" command remotely 
via our telnet object which is connected to 
that remote machine.  If we were to do a 
system('ls -l' . $filename) from this perl script
we should get an empty array unless the file
actually exists on the local machine as well.  But our
intent was to get the size of the file on the remote 
machine.

Now someone pointed out that we could use a 
perl one-liner as the argument to the call to "cmd"
as in 

$cmd = 'perl -e ' .  "'" . 'print -s (' . '"' . $filename . '"' . ');' .
"'";
my @files = $t->cmd($cmd);


This actually works when I use it with telnet on a different UNIX
server(still Solaris 2.6), 
it's just that we haven't installed Perl on our database server -
dunedin - yet.
So maybe I'll have to implement the brute force Perl installation 
solution that Ken Cline recommended last night to make the script a bit
more 
robust!  I'll let you know when perl_world_domination.pl is ready! :-)

Thanks for the reponse!

Rob


Rob Manning                                     manningr at tcsnet.net
Senior Systems Analyst                      Work (410) 396-4963
TeleCommunication Systems               Fax  (410) 837-0546
--
Looking for a  Perl user's group in Baltimore? - http://baltimore.pm.org





More information about the Baltimore-pm mailing list