Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Net FTP -- Size showing different results on AIX system and Linux system

Reply
Thread Tools

Net FTP -- Size showing different results on AIX system and Linux system

 
 
fmbright
Guest
Posts: n/a
 
      08-07-2006
To All:

This is my first post. My name is Frank. I have been using Net FTP
to create an automated FTP process. I developed it on an AIX box (AIX
5.2.0.7) and now want to move it to our Linux box (Redhat). The size
subroutine gives different results when running on the AIX version
Linux box. On the AIX the size functions returns the size of the file
on the FTP while the call on the Linux box returns undefined.

I am calling the same FTP site each time and using the same version of
the script. What else would need to be done to get these version in
sync??

Thanks!


Frank Bright
Univ. of the Arts
215.717.6081
http://www.velocityreviews.com/forums/(E-Mail Removed)

 
Reply With Quote
 
 
 
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      08-07-2006
fmbright wrote:
> This is my first post. My name is Frank.


Hi, Frank. Being new here, you are probably not aware of the posting
guidelines for this group, which you may read online at:

http://www.augustmail.com/~tadmc/clp...uidelines.html

You will notice that the guidelines suggest posting a small, functional
program which demonstrates your problem.

If you had done that, I would be happy to cut-and-paste your code into
my editor and try to reproduce your results (as I have access to both
AIX and Linux systems). Because (had you followed the posting
guidelines) you would have made it very easy to help you.

But you have not made it easy for me to help you. In fact, any help I
would be able to offer would be limited to idle speculation, as I have
no idea what your code looks like.

The posting guidelines are for your benefit - they help you ask a good
question and thus increase the chances of getting a good answer. You
would do well to read them prior to your next posting.

--
David Filmer (http://DavidFilmer.com)

 
Reply With Quote
 
 
 
 
fmbright
Guest
Posts: n/a
 
      08-07-2006
Sorry All!!

My bad.... here is the snipett of the problem. Forgive my spelling,
that is why I went into computers!!

You will see the vars $filetime and $filesize. They record the calls
to mdtm and size. On our AIX box the calls return info. On our linux
box these calls return undef. And we are testing to the same ftp site.

Any suggestions the same calls on two boxes would give two different
results??

FMB

---------------

#!/usr/bin/perl -w
use strict;
use Getopt::Long;
use Net::FTP;
use Time::Local;

use Carp ();
local $SIG{__WARN__} = \&Carp::cluck;

## Variables
my($ftp) = ""; my $login = ""; my $passwd =
"";
my $host = ""; my $host_dir = ""; my $binary = 0;
my $quiet = 0; my $ftp_get = 1; my $ftp_put = 0;
my $localdir = ""; my $debug = 0; my $ascii = 0;
my $date_name = 0; my @rlist = (); my $help = "";
my $anonymous = ""; my $chown = ""; my $chmod = "";
my $before_date = 0; my $after_date = 0;

## Get Command Line Options!
do_get_options();

if ($debug) {
print "Printing settings\n";
print "\t\$login = ".$login ."\n";
print "\t\$passwd = ".$passwd ."\n";
print "\t\$host = ".$host ."\n";
print "\t\$host_dir = ".$host_dir ."\n";
print "\t\$localdir = ".$localdir ."\n";
print "\t\$binary = ".$binary ."\n";
print "\t\$quiet = ".$quiet ."\n";
print "\t\$ftp_get = ".$ftp_get ."\n";
print "\t\$ftp_put = ".$ftp_put ."\n";
print "\t\$debug = ".$debug ."\n";
}

## Check Options -- print help if necessary!
check_options();

## Try getting files (default)
do_get_ftp() unless $ftp_put;

## decrypt with gpg if asekd!
do_decrypt(@rlist) if $decrypt;


exit;

# FTP files from site!
sub do_get_ftp {
$login = "anonymous" if $anonymous; # Set anonymous login.
$anonymou
s
$passwd = $anonymous if $anonymous; # will have user's
email address
!

print "\nStarting FTP!\nAttempting to connect to host ...
".$host if !$q
uiet;
$ftp = Net::FTP->new($host, Debug => $debug)
|| die "\nCannot connect to ".$host.$ftp->message."\n";

print " (Connected!)\nAttempting to login as ... ".$login if
!$quiet;
$ftp->login($login,$passwd)
|| die "\nCannot login to ".$host." -
".$ftp->message."\n";

print " (Logged in!)\n";
print "Changing directory to ".$host_dir."\n" if !$quiet &&
$host_dir;
$ftp->cwd($host_dir) || die "Cannot change to directory
".$host_dir." -
".$ftp->message if $host_dir;
$host_dir = $ftp->pwd if !$host_dir;
print "Current directory ".$host_dir."\n" if !$quiet;

print "Setting transfer mode to binary\n" if !$quiet &&
$binary;
$ftp->binary || die "Cannot set transfer mode to binary -
".$ftp->messag
e if $binary;

print "Setting transfer mode to ASCII\n" if !$quiet && $ascii;
$ftp->ascii || die "Cannot set transfer mode to ascii -
".$ftp->message
if $ascii;

print "Retrieving files ...\n" if !$quiet;
print " ...saving to folder $localdir\n" if $localdir &&
!$quiet;
print " ...before ".&print_time($before_date) if $before_date
&& !$quie
t;
print " ...after ".&print_time($after_date) if !$quiet &&
$after_date;
print " ...using filter -> ".$ftp_patt."\n" if $ftp_patt &&
!$quiet;
my($list)=$ftp->ls() || die "Cannot retrieve files from
directory - ".$h
ost_dir."\n".$ftp->message."\n";
$ftp_patt =~ s/\.\.\./.*/g if $ftp_patt; $ftp_patt =~
s/\?/.?/g if $ft
p_patt;
@$list = grep(/$ftp_patt/, @$list) if $ftp_patt; # Apply
pattern filt
er!
foreach my $get (@$list) {
my $local_put = ($localdir) ? $localdir."/".$get :
$get;
my $filetime = $ftp->mdtm($get);
my $filesize = $ftp->size($get);
my $y = &pass_date_filter($filetime);
if ($y) {
$ftp->get("$get", $local_put) || die "\nFailed
retrievin
g $_ ->".$ftp->message."\n";
print " ".$get." ".&print_time($filetime)."
".$files
ize."\n" if !$quiet;
push @rlist,$local_put;
}
}
print "No files were retrieved!\n" if !$quiet && !@rlist;
print "Finished retrieving files!\n" if !$quiet && @rlist;
print "Disconnecting!\n" if !$quiet;
$ftp->quit() || die "Failed to quit ftp!\n", $ftp->message;
}

sub print_time {
my $x = shift;
my @x = localtime($x);
return sprintf("%02d.%02d.%04d", $x[4]+1, $x[3], $x[5]+1900);
}

sub get_date_name {
my @x = localtime(time);
return sprintf("_%02d%02d%4d",$x[4]+1,$x[3],$x[5]+1900);
}

sub pass_date_filter {
my $x = shift;
return 1 if !$before_date && !$after_date;
return 1 if $before_date && $after_date && $x < $before_date &&
$x > $af
ter_date;
return 1 if $before_date && $x < $before_date && !$after_date;
return 1 if $after_date && $x > $after_date && !$before_date;
return 0;
}


fmbright wrote:
> To All:
>
> This is my first post. My name is Frank. I have been using Net FTP
> to create an automated FTP process. I developed it on an AIX box (AIX
> 5.2.0.7) and now want to move it to our Linux box (Redhat). The size
> subroutine gives different results when running on the AIX version
> Linux box. On the AIX the size functions returns the size of the file
> on the FTP while the call on the Linux box returns undefined.
>
> I am calling the same FTP site each time and using the same version of
> the script. What else would need to be done to get these version in
> sync??
>
> Thanks!
>
>
> Frank Bright
> Univ. of the Arts
> 215.717.6081
> (E-Mail Removed)


 
Reply With Quote
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      08-07-2006
fmbright wrote:
> Sorry All!!
>
> My bad.... here is the snipett of the problem.


Your bad again. That's not a snippet. That's over 100 lines, many of
which wrap.

I think you missed the point of the suggestion in the guidelines. Let's
review:

>> First make a short (less than 20-30 lines) and complete program that
>> illustrates the problem you are having. People should be able to run
>> your program by copy/pasting the code from your article. (You will
>> find that doing this step very often reveals your problem directly.


That doesn't mean cut-and-paste your entire program. That means pare
your program down into the smallest and simplest program which
demonstrates the problem. That would not include dozens of lines of
debugging code or subroutines to do date and time manipulation (as
these are not relevant to your question).

There have been many times that I have considered posting a question to
usenet. In the process of preparing my question, I have rewritten my
code per the guidelines and, in doing so, have discovered the answer to
my own question. I have found that this is a great debugging
technique.

Also, the CLPMisc guidelines first refer you to general guidelines
which are applicable to any technical group (namely
http://www.catb.org/~esr/faqs/smart-questions.html). Those guidelines
wisely suggest that you limit your linewidth. Some newsreaders
(including your own 'reader', GoogleGroups) wrap long lines, which
impedes readability, and if cut-and-pasted into an editor, those would
come in as two different lines. It's wise to not exceed 70 columns
(that gives a few spare columns if someone wants to quote-back code
without it wrapping).

--
David Filmer (http://DavidFilmer.com)

 
Reply With Quote
 
Simon Taylor
Guest
Posts: n/a
 
      08-08-2006
Hello Frank,

> This is my first post. My name is Frank. I have been using Net FTP
> to create an automated FTP process. I developed it on an AIX box (AIX
> 5.2.0.7) and now want to move it to our Linux box (Redhat). The size
> subroutine gives different results when running on the AIX version
> Linux box. On the AIX the size functions returns the size of the file
> on the FTP while the call on the Linux box returns undefined.
>
> I am calling the same FTP site each time and using the same version of
> the script. What else would need to be done to get these version in
> sync??


As others have said, the discipline of creating the smallest possible
instance of your problem often highlights the problem directly.

Nonetheless, I'm feeling generous, so see below for the sort of
example they're talking about.

Once you've modified the code to supply sensible values for
$host, $login and $passwd, do you really get different results
talking to the same ftp server from Linux and from AIX?

Regards,

Simon Taylor
--
www.perlmeme.org


#!/usr/bin/perl
use strict;
use warnings;
use Net::FTP;

my $host = 'nnn.nnn.nnn.nnn';
my $debug = 0;
my $login = 'xxxxxx';
my $passwd = 'xxxxxx';
my $host_dir = '/tmp';
my $file = 'some_file';

my $ftp = Net::FTP->new($host, Debug => $debug)
or die "Cannot connect to $host";

$ftp->login($login, $passwd)
or die "Cannot login to $host";

$ftp->cwd($host_dir)
or die "Cannot change to directory $host_dir";

$ftp->binary()
or die 'Cannot set transfer mode to binary';

my $filesize = $ftp->size($file);
print "Filesize: $filesize\n";

$ftp->quit();
exit 0;
 
Reply With Quote
 
l v
Guest
Posts: n/a
 
      08-08-2006
fmbright wrote:
> To All:
>
> This is my first post. My name is Frank. I have been using Net FTP
> to create an automated FTP process. I developed it on an AIX box (AIX
> 5.2.0.7) and now want to move it to our Linux box (Redhat). The size
> subroutine gives different results when running on the AIX version
> Linux box. On the AIX the size functions returns the size of the file
> on the FTP while the call on the Linux box returns undefined.
>
> I am calling the same FTP site each time and using the same version of
> the script. What else would need to be done to get these version in
> sync??
>
> Thanks!
>
>
> Frank Bright
> Univ. of the Arts
> 215.717.6081
> (E-Mail Removed)
>


Are your Net::FTP modules the same version?

--

Len
 
Reply With Quote
 
fmbright
Guest
Posts: n/a
 
      08-08-2006
Len,

I installed the latest copies from CPAN and installed the lastest
version of Perl on both boxes. Could the different unixes make
different results??

Thanks!

Frank

l v wrote:
> fmbright wrote:
> > To All:
> >
> > This is my first post. My name is Frank. I have been using Net FTP
> > to create an automated FTP process. I developed it on an AIX box (AIX
> > 5.2.0.7) and now want to move it to our Linux box (Redhat). The size
> > subroutine gives different results when running on the AIX version
> > Linux box. On the AIX the size functions returns the size of the file
> > on the FTP while the call on the Linux box returns undefined.
> >
> > I am calling the same FTP site each time and using the same version of
> > the script. What else would need to be done to get these version in
> > sync??
> >
> > Thanks!
> >
> >
> > Frank Bright
> > Univ. of the Arts
> > 215.717.6081
> > (E-Mail Removed)
> >

>
> Are your Net::FTP modules the same version?
>
> --
>
> Len


 
Reply With Quote
 
fmbright
Guest
Posts: n/a
 
      08-10-2006
Hi Len,

I get the correct filesizes when I do an ftp from both boxes. And when
I do a windows FTP to the site.

FMB

l v wrote:
> fmbright wrote:
> > Len,
> >
> > I installed the latest copies from CPAN and installed the lastest
> > version of Perl on both boxes. Could the different unixes make
> > different results??
> >
> > Thanks!
> >
> > Frank
> >
> > l v wrote:
> >
> >>fmbright wrote:
> >>
> >>>To All:
> >>>
> >>>This is my first post. My name is Frank. I have been using Net FTP
> >>>to create an automated FTP process. I developed it on an AIX box (AIX
> >>>5.2.0.7) and now want to move it to our Linux box (Redhat). The size
> >>>subroutine gives different results when running on the AIX version
> >>>Linux box. On the AIX the size functions returns the size of the file
> >>>on the FTP while the call on the Linux box returns undefined.
> >>>
> >>>I am calling the same FTP site each time and using the same version of
> >>>the script. What else would need to be done to get these version in
> >>>sync??
> >>>
> >>>Thanks!
> >>>

>
> I don't know. What file sizes do you get when you use native ftp
> clients on each box?
> --
>
> Len


 
Reply With Quote
 
usenet@DavidFilmer.com
Guest
Posts: n/a
 
      08-10-2006
fmbright wrote:
> I get the correct filesizes when I do an ftp from both boxes. And when
> I do a windows FTP to the site.


I believe folks are still waiting for your small complete sample
program which illustrates your problem (similar to the example that
Simon kindly posted).

I don't think you have yet grasped the importance of this aspect of
asking a good question. Allow me to demonstrate...

I was recently having problems working with a server (a news server,
not an FTP server, but that doesn't really matter). My "problem
program" is hundreds of lines long with lots of comments and debugging.
But take a look at the question I posted:

http://tinyurl.com/mw9jh
or <(E-Mail Removed). com>

Notice a SHORT (only a dozen lines) but COMPLETE example of the
specific problem I was having which anyone in usenet could
cut-and-paste into their editor and try it out. And, whadda ya know,
somebody did!

Notice that about an hour later, a responder had kindly identified the
source of the problem, and about an hour after that he kindly furnished
code which illustrated and corrected my problem. We had further
productive conversation where I learned some more about the module I
was using (including some methods that aren't in the perldocs).

In less than three hours, I knew EXACTLY what was wrong and EXACTLY how
to fix it. That's because I got a good answer. One of the most
important reasons why I got a good answer was because I asked a good
question. I closely conformed to the CLPMisc posting guidelines and I
got polite, fast, and expert help.

I got a good answer in three HOURS. You still have not gotten a good
answer after three DAYS. That's because you STILL have not asked a
good question. We have described the task; we have pointed you to the
guidelines; we have given you a nearly-complete example. We have TRIED
to show you how to ask a good question but you persist in ignoring our
advice.

The only person that harms is you.

--
David Filmer (http://DavidFilmer.com)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using ajax call to fetch multiple results from multiple queries and showing them 1 by 1 as the results comes. Biranchi Narayan Panda ASP .Net 0 02-21-2010 03:46 PM
putenv for AIX and ifdef for AIX ClownPleco C Programming 5 08-24-2007 02:15 PM
AIX / HP-UX "ps" command results from many machines DRS.Usenet@sengsational.com Java 1 07-13-2006 09:14 PM
Looking for AIX 5.2 binaries, IS anyone running Ruby on AIX 5.2 ?? bww00amdahl@yahoo.com Ruby 5 07-08-2005 11:54 AM
Net::FTP problems getting files from Windows FTP server, but not Linux FTP Server. D. Buck Perl Misc 2 06-29-2004 02:05 PM



Advertisments