?
Solved

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

Posted on 2004-08-18
7
Medium Priority
?
217 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
  • 2
  • 2
5 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
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
Suggested Courses

750 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