This is a discussion on FTP function using PERL within the Perl forums, part of the Software Development category; hi all, i have given simple code for reading data from a file using PERL FTP Functions. eg: #!/usr/bin/...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| hi all, i have given simple code for reading data from a file using PERL FTP Functions. eg: #!/usr/bin/perl use Net::FTP; my $host="test.com"; my $directory="pub"; $ftp=Net::FTP->new($host,Timeout=>240) or $newerr=1; push @ERRORS, "Can't ftp to $host: $!\n" if $newerr; myerr() if $newerr; print "Connected\n"; $ftp->login("ftp","apl\@") or $newerr=1; print "Getting file list"; push @ERRORS, "Can't login to $host: $!\n" if $newerr; $ftp->quit if $newerr; myerr() if $newerr; print "Logged in\n"; $ftp->cwd($directory) or $newerr=1; push @ERRORS, "Can't cd $!\n" if $newerr; myerr() if $newerr; $ftp->quit if $newerr; @files=$ftp->dir or $newerr=1; push @ERRORS, "Can't get file list $!\n" if $newerr; myerr() if $newerr; print "Got file list\n"; foreach(@files) { print "$_\n"; } $ftp->quit; sub myerr { print "Error: \n"; print @ERRORS; exit 0; } |
| Sponsored Links |
| |||
| FTP is a client-server protocol. That is, there's a server which listens for connections on an agreed-upon port address (FTP uses 21 by default). Once a connection is made, the server allocates a new port for communication with the client. This leaves port 21 free to accept the connection from the next client. The client and server communicate conversationally, with the client sending commands defined in the FTP protocol to the server, and the server sending responses back to the client. This is the architecture for many well known protocols on the Internet such as SMTP, NNTP, and HTTP. Here's an example of a conversation between an FTP server and a client. It shows what communication is necessary to connect, login, change directory and retrieve a file. The commands sent from the client to the server are shown in bold. 220 ftphost FTP server (SunOS 4.1) ready. USER anonymous 331 Guest login ok, send ident as password. PASS perl-journal-staff@perl.com 230 Guest login ok, access restrictions apply. CWD pub 250 CWD command successful. PWD 257 "/pub" is current directory. PORT 127,0,0,1,16,110 200 PORT command successful. RETR testfile 150 ASCII data connection for testfile (127.0.0.1,4206) (0 bytes). 226 ASCII Transfer complete. QUIT 221 Goodbye. For more visit the following link... FTP: File Transfer Using Perl - The Perl Journal, Autumn 1996
__________________ S.VinothkumaR Behind me is infinite power, Before me is Endless Possibility, Around me is Boundless Opportunity, Why should I fear! |
![]() |
| Thread Tools | |
| Display Modes | |
| |
LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/perl/3531-ftp-function-using-perl.html | |||
| Posted By | For | Type | Date |
| Perl [Archive] - DiscussWeb IT Community - Technical Support and Technology Discussions | This thread | Refback | 03-13-2008 01:21 PM |
| DiscussWeb IT Community - Technical Support and Technology Discussions | This thread | Refback | 08-29-2007 10:10 PM |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| what is perl? | inder | Perl | 2 | 09-25-2008 04:10 AM |
| How will use perl function in php page? | raj | PHP Programming | 17 | 08-14-2007 07:30 AM |
| How to set Perl Interpreter within perl script | sivaramakrishnan | Perl | 1 | 07-19-2007 05:45 AM |
| Diff inline function and ordinary function | vigneshgets | C and C++ Programming | 1 | 05-24-2007 10:34 AM |
| Perl? | swoosh | Perl | 2 | 03-19-2007 03:31 AM |