?
Solved

how do you get a full listing of files, using net:ftp

Posted on 2004-08-18
7
Medium Priority
?
212 Views
Last Modified: 2010-03-05
here are the script:

use Net::FTP;
$ftp = Net::FTP->new("$hname", Timeout => 30, Debug=>1)   ;
$ftp->login("$uname", "$pword")        ;
$ftp->cwd("$rdir")                     ;
$ftp->binary;
@dirlst = $ftp->pwd;
@filelst = $ftp->dir("*.csv");
print STDERR "","\n";
print STDERR @dirlst,"\n";
foreach $flist (@filelst) {
  print STDERR $flist,"\n";
  print STDERR "","\n";
}
$ftp->quit()


here are the output:

/reports
-r--r--r--   1 owner    group           49267 Aug 18 12:14 Retail.csv

-r--r--r--   1 owner    group           49267 Aug 18 12:33 Retail.csv



How do I show the owner of the file, the way it is now, it just say "owner"
0
Comment
Question by:matgold
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
7 Comments
 
LVL 13

Expert Comment

by:gripe
ID: 11835882
Is it possible that you're connecting to a windows-based FTP server or an FTP server that does not understand the concept of user/group in this context? Or an ftp server that simply assigns a generic owner/group name to all files?

Your code works as expected when I try it. The output you're seeing is coming from the server itself and is simply passed back by Net::FTP. Net::FTP does not modify the data that comes from a LIST command in any way, so the owner/group names you're seeing are coming from the server itself.

You can isolate the problem a bit more by connecting to the ftp site manually with the command line ftp program. (Usually /usr/bin/ftp on *NIX or C:\windows\system32\ftp.exe on windows) Try a dir command once connected and note the output. You should see the same owner/group names.
0
 
LVL 48

Expert Comment

by:Tintin
ID: 11836113
What did you expect the owner to be?

In your case the owner is 'owner' and the group is 'group'.  That is something set on the Unix server unless it is running a very, very strange FTP server.
0
 

Author Comment

by:matgold
ID: 11836412
yes, it is a windows-base FTP server.
I'm looking for an output, that looks like from dos command "dir /q"
Below is from dos command.

08/02/2004  11:30a             386 LROBERT    mansits_08022004.csv
0
 
LVL 13

Accepted Solution

by:
gripe earned 200 total points
ID: 11836735
The problem is with your FTP server.. you can't change this in the perl script. Your FTP server must be configured to show the actual owners of files as they are known to the windows server, if this is even possible. The output you are seeing is expected and normal.

What is the manufacturer/product name of the FTP server you (or the site you are connecting to) is using? It's possible that there is a configuration option to do what you want in the FTP server.

In the meantime, if this is a programming issue, perhaps there's another way to do what you want if you think about it a different way. What are you trying to do exactly? Why is the owner/group important in your script?
0
 

Author Comment

by:matgold
ID: 11841967
I just want to know, who is modifying/creating files.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question