Your 'value added combination example'

Manning, Rob Rob_Manning at
Wed Nov 3 10:11:27 CST 1999

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

		A quicker way may be to use the -s filetest

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


		Just butting in...

	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


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 

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
robust!  I'll let you know when is ready! :-)

Thanks for the reponse!


Rob Manning                                     manningr at
Senior Systems Analyst                      Work (410) 396-4963
TeleCommunication Systems               Fax  (410) 837-0546
Looking for a  Perl user's group in Baltimore? -

More information about the Baltimore-pm mailing list