Getting a whole directory using Net::FTP

Hi,

I would like to upload and download files to a Linux server from my 
Windows machine. So, I set out to write a little script that does just 
that. Uploading, it turns out, is no problem. I use an "opendir" 
statement to open the directory, then readdir to read its contents and 
then each file gets "put". This works and so, I thought, that's what 
I'll do for downloading files too. However, I don't seem to be able to 
open the remote directory. I get the message that the $dir cannot be 
opened ("Ik kan $dir niet openen!"). I added a snippet of code below.

Can anybody tell what is going on here and how I can fix this?

best,

Ruben van de Vijver


....
#my $dir = $ftp->cwd("/home/ruben/journal/"); #this is wrong!
                                                                        
#the value of $dir is 1.

#alternative:
$ftp->cwd("/home/ruben/journal/");       #it now indicates, through 
$ftp->pwd(); that I am in "/home/ruben/journal/"
$dir = "/home/ruben/journal/";
opendir (IN, $dir) or die "ik kan $dir niet openen!";
my @files = readdir(IN);
foreach my $file(@files){
$ftp->get("$file");
}
$ftp->quit
.....

0
ruben
3/6/2003 8:45:12 AM
perl.beginners 29388 articles. 4 followers. Follow

2 Replies
622 Views

Similar Articles

[PageSpeed] 59

On Thu, 6 Mar 2003, ruben van de vijver wrote:

> Hi,
> 
> I would like to upload and download files to a Linux server from my 
> Windows machine. So, I set out to write a little script that does just 
> that. Uploading, it turns out, is no problem. I use an "opendir" 
> statement to open the directory, then readdir to read its contents and 
> then each file gets "put". This works and so, I thought, that's what 
> I'll do for downloading files too. However, I don't seem to be able to 
> open the remote directory. I get the message that the $dir cannot be 
> opened ("Ik kan $dir niet openen!"). I added a snippet of code below.
> 
> Can anybody tell what is going on here and how I can fix this?
> 
> best,
> 
> Ruben van de Vijver
> 
> 
> ...
> #my $dir = $ftp->cwd("/home/ruben/journal/"); #this is wrong!
>                                                                         
> #the value of $dir is 1.
> 
> #alternative:
> $ftp->cwd("/home/ruben/journal/");       #it now indicates, through 
> $ftp->pwd(); that I am in "/home/ruben/journal/"
> $dir = "/home/ruben/journal/";
> opendir (IN, $dir) or die "ik kan $dir niet openen!";

This opens $dir in your working machine (winblows), not on the remote 
machine (linux).

Take a look at the ls or dir method in Net::FTP
perldoc Net::FTP

> my @files = readdir(IN);
> foreach my $file(@files){
> $ftp->get("$file");
> }
> $ftp->quit
> ....
> 
> 
> 

0
sraghav
3/6/2003 8:51:04 AM
Ruben,

The ls method will return an array of filenames.
It worked fine for me.
Also, add "or die" to each of the methods you use.
My experience with FTP is that it tends to "die" once in a while, resulting
in incomplete directory lists etc....

Cheers,
Michael.

"Ruben Van De Vijver" <ruben@ling.uni-potsdam.de> schreef in bericht
news:3E670A98.2040707@ling.uni-potsdam.de...
> Hi,
>
> I would like to upload and download files to a Linux server from my
> Windows machine. So, I set out to write a little script that does just
> that. Uploading, it turns out, is no problem. I use an "opendir"
> statement to open the directory, then readdir to read its contents and
> then each file gets "put". This works and so, I thought, that's what
> I'll do for downloading files too. However, I don't seem to be able to
> open the remote directory. I get the message that the $dir cannot be
> opened ("Ik kan $dir niet openen!"). I added a snippet of code below.
>
> Can anybody tell what is going on here and how I can fix this?
>
> best,
>
> Ruben van de Vijver
>
>
> ...
> #my $dir = $ftp->cwd("/home/ruben/journal/"); #this is wrong!
>
> #the value of $dir is 1.
>
> #alternative:
> $ftp->cwd("/home/ruben/journal/");       #it now indicates, through
> $ftp->pwd(); that I am in "/home/ruben/journal/"
> $dir = "/home/ruben/journal/";
> opendir (IN, $dir) or die "ik kan $dir niet openen!";
> my @files = readdir(IN);
> foreach my $file(@files){
> $ftp->get("$file");
> }
> $ftp->quit
> ....
>


0
dmmich
3/11/2003 8:05:26 PM
Reply:

Similar Artilces:

using GET of NET::FTP
get ($remote,$local,$where) is failing whenever i use the third arguement. here in this case my file to be downloaded from FTP is of size 5MB. 2Mb of it is downloaded, now when i am executing the get ($remote,$local,$where) with $where as 2MB(2048), get method is returning me nothing and download is getting aborted. can anybody plz help me out to solve this problem. ...

Getting the file creation time using Net::FTP
Hi to All, Currently, I'm doing a script using the Net::FTP module, this script will just get all the files created on a particular date. The problem right now (which I'm stuck) is that some files don't have creation date and time included in their filename so there's no way I can get those files by not specifying the creation time. Base on the man page for Net::FTP, mdtm() returns the modification time of the file but it did not return anything. Here's a snippet: $file = "sample_file"; $ftp = Net::FTP->new("hostname"); $ftp->logi...

Display user's fullname using Active Directory in asp.net using c#.net
Hi all, In my company, there is a requirement,where we are designing an intra-web portal which should automatially the user's full name once the portal is opened. It need to use any login page or from any other database. I want my home page to display "Welcome <firstname> <lastname>" once the user types the URL of that portal. The user information is retrieved through the system's logged usernname, which i can fetch using "Environment.username" and "Environment.userDomainName" etc.  Now i want to validate that username which will be ou...

Is it possible to get the path using Virtual directory asp.net project
I worked on a asp.net project solution. But i am unable to find in the windows explorer. But i know the virtual directory name for that project. I went to IIS admin and to default websites info, I see the virtual directory with all the files, But can you please tell me how i can find the path of all the project files. where it is located on the C: drive of my computer. Thank you very much. Once you have found the virtual directory in IIS admin, right click on the directory. there should be a "local path" text box towards the top of the virtual directory tab. Ho...

Getting User List from Active Directory using LDAP with Asp.Net
Dear All, Did any body worked on the below process? Getting User List from Active Directory using LDAP with Asp.Net. If Yes, Can u pls guide me to proceed? warm regards, Minor. Not sure if that was supposed to be a hyperlink or not in your post.  However, you should start with the first post in this forum for common patterns.  You are looking for all users, so you can use "(&(objectClass=user)(objectCategory=person))" as your search filter.  Ryan DunnWeblog The BookLDAP Programming Help...

How to get new web app to use .NET 2.0 on Win2K server using .NET 1.1 as default framework?
I have .net framework1.1 and 2.0 on our server running win2K. i have existing applications that uses asp.net 1.1, i also have a new app that use ASP.net 2.0.  how can i set my new .NET 2.0 app to point to asp.net 2.0 without messing up my existing .NET 1.1 apps? To specify the ASP .Net version fro a web application, do the followingIn IIS Manager select the web application -> Properties -> ASP.Net TabSelect  ASP.Net version you want to use for the applicationRegards,PrashantDont forget to click "Mark as Answer" on the post that helped you. But I am running Win2K...

getting error while Creating a user account in Active Directory using C#.Net
Hi, when CommitChanges() method get executed, the Following error is coming: [System.DirectoryServices.DirectoryServicesCOMException] = {"An invalid dn syntax has been specified. (Exception from HRESULT: 0x80072032)"} My Code is as follws:public void CreateUserAccountAd() { try {string strUser = "CN=CGGDEV" + @"\" + "userSantoshi"; string strPassword = "ssss#1234";DirectoryEntry de = new DirectoryEntry("LDAP://WINDEV/CN=Users,DC=cgg,DC=gov,DC=in", "administrator", "admin", AuthenticationTypes.Secure); ...

can I get a list of virtual directories on IIS 5 using VB.net?
Is there any way to do that? thanks HFThanks a lot, HF I'm trying to create a dynamic treeview to include all web application on my IIS 5. So far I succeeded in listing all direcotories on "root\inetpub\wwwroot\" folder to any depth http://68.46.129.180/myprojects . However I can't include (dynamically) applications located outside the wwwroot folder. thanks Thanks a lot, HF...

automatic FTP not using NET:FTP module
Hi, I have to automate ftp process using perl or shell scripts. At the moment I cannot install NET:FTP class. So any pointers for me on how do this. thanks, vas _______________________________________________________ Send a cool gift with your E-Card http://www.bluemountain.com/giftcenter/ On Wed, Jul 11, 2001 at 10:20:58AM -0700, srinivas.s@excite.com wrote: > I have to automate ftp process using perl or shell scripts. At the moment I > cannot install NET:FTP class. So any pointers for me on how do this. Why can't you install Net::FTP? Really, it&#...

Get ftp directory list from ftp server
Hi Firstly Thanks for any help that is given. What I want to do is using a web service connected to an FTP server using a Auth TLS connection and generate a full ftp directory listing. Is This Possible ?? Regards ...

Getting error (logon failure: bad user name) when trying to create a directory using impersonation in asp.net
try  {                LogonUser ("[NETWORK USER NAME (WITHOUT DOMAIN)]",                        "DOMAIN NAME",                        "DOMAIN PASSWORD",                 ...

Sending SMS using vb.net or C#.net using vb.net or c#.net
Hi  My requirement is I hav one csv file with these fields id,mobilenum,messgae,status.intiallu staus is 0. once i read the all fileds and take that mobile number.using tat mobile number  i need to send sms .after sending sms i shuld change status as 1 How to send sms thru coding (please dont provide any links.if it is provide also please give working links becox i checked codeproject .i didnt get any nice link. and also provide the how to update the status field im csv file   Thank ssandhya   To send SMS, you need some third party SMS providers. if you consul...

FTP not using NET:FTP module ... Why dose this work???
Hi Using Luke Bakkens reply >If you can't install Net::FTP, the following works with the ftp.exe >program on NT to get the file /tmp/frazzle in binary mode: > >open FTP, "> tmpftp.$$"; >print FTP <<EOF; >$username >$password >bin >get /tmp/frazzle >bye >EOF >close FTP >system "ftp -s:tmpftp.$$ $hostname"; >unlink tmpftp.$$ > >on unix, the system call would be this i believe: >system "ftp $hostname < tmpftp.$$"; > >good luck >Luke I went and did the following, but ...

RE: ftp w/o using Net::FTP
James P Donnelly <jpd4@cisunix.unh.edu> asked: > I am only trying to login into a server, travese to the > correct directory, dump a file and quit. I have hacked > together something that gets me to the server and > then it seems to hang at the login.. Has anyone written > something like > this w/o use of the module? Any insight would be very helpful > > Thanks -- Jim > > > $cmd = 'rftp'; > $rftp_commands = > "open > $fHost > $user > $...

Web resources about - Getting a whole directory using Net::FTP - perl.beginners

Wikipedia:Quick directory - Wikipedia, the free encyclopedia
This page is a handy directory to various locations of interest in Wikipedia. Only dynamic pages should be listed here, no policy pages etc. ...

Wikipedia:WikiProject Council/Directory - Wikipedia, the free encyclopedia
Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. , a non-profit organization.

Business Directory Listings: Eight Smart Tips for You to Get Started
If you are considering a business directory listing for your small business, congratulations – you are on the right track. Local SEO, local customers, ...

LinkedIn Lookup iOS app aims to replace your company’s awful intranet employee directory
... continue reading at 9to5Mac . What do you think? Discuss "LinkedIn Lookup iOS app aims to replace your company’s awful intranet employee directory" ...

Atlas Partner Directory Launched
... just for Facebook and Instagram –advertising platform Atlas has one, as well. On that note, Atlas Tuesday introduced the Atlas Partner Directory ...

Slack announces App Directory store
... create more apps for the store, and a new framework called Botkit which should simplify the process of creating apps. The Slack App Directory, ...

The British Library’s ‘Save Our Sounds’ Program Creates Directory of UK Sound Collections
The long-feared deterioration of the world's sound collections is a coming to a head with the British Library's last-ditch initiative called ...

Researchers show how to steal Windows Active Directory credentials from the Internet
... showed at the Black Hat security conference. The attack, called an SMB relay, causes a Windows computer that's part of an Active Directory ...

Researchers find way to steal Windows Active Directory credentials from the Internet
The technique could enable attackers to attack Windows servers hosted in the cloud

Slack's App Directory proves it's more than just a chatroom
... are about to get a little easier to find and integrate within your team and over 160 of them live within the company's new Slack App Directory. ...

Resources last updated: 12/27/2015 3:43:21 AM