Solved

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

Posted on 2004-08-18
7
171 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
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 50 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now