Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

lcd in Net::FTP module

by gopalr (Priest)
on Aug 04, 2009 at 07:01 UTC ( [id://785663]=perlquestion: print w/replies, xml ) Need Help??

gopalr has asked for the wisdom of the Perl Monks concerning the following question:

We are using the following to change remote directory

$ftp->cwd($remot_root).

Please guide me, how to change local directory. I used $ftp->lcd($local_directory), but is showing an error message Can't locate object method "lcd" via package "Net::FTP" at XXXXX_FTP.pl line 82.

Please guide me. Thanks in Advance!!

Thanks,
Gopal.R

Replies are listed 'Best First'.
Re: lcd in Net::FTP module
by derby (Abbot) on Aug 04, 2009 at 11:04 UTC

    While lcd makes sense when you're in an interactive FTP session, you really don't need it when scripting (at least with perl) -- use the built-in chdir function:

    use Net::FTP; my $ftp = Net::FTP->new("some.host.name", Debug => 0) or die "Cannot connect to some.host.name: $@"; $ftp->login("anonymous",'-anonymous@') or die "Cannot login ", $ftp->message; $ftp->cwd("/pub") or die "Cannot change working directory ", $ftp->message; chdir "/tmp" or die "Cannot change local directory ", $!; $ftp->get("that.file") or die "get failed ", $ftp->message; $ftp->quit;
    (modified from the example at Net::FTP).
    -derby
Re: lcd in Net::FTP module
by Anonymous Monk on Aug 04, 2009 at 08:01 UTC
Re: lcd in Net::FTP module
by Khen1950fx (Canon) on Aug 04, 2009 at 08:56 UTC
    If you were using straight ftp, then you would use cd to change directory on the remote, and you would use lcd to change the local directory. However, there is no cd or lcd in Net::FTP, at least none that I can find. The "cwd" command should work for both remote and local directories.
Re: lcd in Net::FTP module
by Selvakumar (Scribe) on Aug 04, 2009 at 11:26 UTC
    Net::FTP to process ftp and explain more details about the requirement of change local directly to get exact answer. opendir cammand to read all the files from your local directory.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://785663]
Approved by vinoth.ree
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-03-19 09:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found