Sponsored Content
Full Discussion: perl + Net::FTP::Recursive
Top Forums Shell Programming and Scripting perl + Net::FTP::Recursive Post 38306 by Optimus_P on Friday 11th of July 2003 12:24:56 PM
Old 07-11-2003
perl + Net::FTP::Recursive

Problem:
It will not advance to the next user in the list. It always dies right after it sends the 2/2 files from the first users dir.

Code:
$USERLIST="/export/home/mxdooley/perl_ftp/userlist";
$USER_DIR="/export/home/mxdooley/perl_ftp/homes";
$FTP_OUT_DIR="/export/home/mxdooley/perl_ftp/recieved";


sub ftp_out {
        print "SUB USER=$uname PASS=$pass HOST=$host\n";

        $ftp = Net::FTP::Recursive ->new("$host", Debug => 1) or die "HOST ERROR: ($@) ";
        $ftp->login("$uname","$pass") or die "UNAME/PASS ERROR: ",$ftp->message;
        $ftp->cwd("$FTP_OUT_DIR") or die "CWD ERROR: ",$ftp->message;
        $ftp->rput("${USER_DIR}/${uname}/*") or die "RPUT ERROR:",$ftp->message;
        #$ftp->quit;
}

open (USERLIST, $USERLIST) || die "MIKE ERROR: ($!)";
foreach (<USERLIST>) {
        chomp;
        push(@ULIST,$_);
}


foreach (@ULIST) {
        ($uname ,$pass ,$host)= split(/:/, $_);
	chdir ("$USER_DIR/$uname") || die "NO GO ($!)";
	ftp_out($uname ,$pass ,$host);
}

-- OUTPUT --
RPUT ERROR:ASCII data connection for test.synthium (10.40.11.28,44879).
Transfer complete.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Recursive FTP

I am trying to write a recursive FTP script and have come to a point where I need to test if the file is either a normal ascii file or a directory. My question is how do I test if the file is either ascii or directory. (1 Reply)
Discussion started by: aslamg
1 Replies

2. Shell Programming and Scripting

PERL: NET::FTP..>Debug Messages

HI All, NET::FTP->new($server, DEBUG=>1); I need to get all the Debug Messages in an array or a file.... Please suggest!! (0 Replies)
Discussion started by: angad.makkar
0 Replies

3. Shell Programming and Scripting

Recursive FTP -- here at last.

Over the past few weeks, I saw a couple of threads requesting recursive ftp: Copying files between 2 Unix server ftp from NT to UNIX I decided to try to write a script to accommodate these requests. The result is HardFeed. Here are a few examples of what it can do. HardFeed ftpserver... (52 Replies)
Discussion started by: Perderabo
52 Replies

4. Shell Programming and Scripting

Corrupted Download with Net::FTP (perl)

Hello, I am trying to download several files from a remote FTP server using Net::FTP from within a perl script. The files download alright, except they appear to be corrupted. I know this because once after downloading, I use bzcat to pipe the files to a split command, and bzcat complains saying... (3 Replies)
Discussion started by: amcrisan
3 Replies

5. Shell Programming and Scripting

Net::Ftp in perl

I am trying to execute a script in another server, i used Net::Ftp module How to execute unix command in another server by using Net::Ftp module.. #!/usr/bin.perl ### Perl script to $ftp->login($user_name,'password') or die "Cannot login ", $ftp->message;... (2 Replies)
Discussion started by: pritish.sas
2 Replies

6. Shell Programming and Scripting

Perl - Net::FTP issue

Wondering if anyone can help or advise on following issue. The below script should simply connect to a different server and retrieve certain files for me. use lib "/xxxxx/xxxxx/xxxxx/xxxx"; use Net::FTP; my $directory = "xxxxxxxx"; my $destinationDir = "xxxxxxxxx"; my $filePrefix =... (1 Reply)
Discussion started by: meevagh
1 Replies

7. Shell Programming and Scripting

NET::FTP Problem

I am facing some problem in the NET::FTP Library in perl script in the HPUX. I am using NET::FTP to ftp files from 23 remote servers. Except 1 server everything is working fine. I am getting this error from one server . but normal FTP is working fine for that server. everytime few files are ftped... (1 Reply)
Discussion started by: mohanm
1 Replies

8. UNIX for Dummies Questions & Answers

recursive search and ftp

Could someone help me in recursive search and ftp'ing the files to remote server? The host machine will have /dir1/dira/list_of_files1 /dir1/dirb/list_of_files2 /dir1/dirc/list_of_files3 . . . so., I need to search from dir1 recursively (only one level down) and find all the files that... (1 Reply)
Discussion started by: brahmi
1 Replies

9. HP-UX

[Solved] Unable to rename file in ftp server .Net:FTP perl

Hello All, I am trying to connect to ftp server and get the files. Also i need to rename the file in other ftp dir. rename method is not allowing me to rename the file in other dir. When i tried copy command by using net::FTP:FILE then perl says it is not installed. Can some body help me to... (2 Replies)
Discussion started by: krsnadasa
2 Replies

10. Shell Programming and Scripting

Unable to get the size of remote file using Net::FTP Perl Script

Hi, I am using below piece of code to get the size of the remote file. $ftp->cwd($destination) or $error=$ftp->message; if(!$error) { $ftp->put($file) or $error=$ftp->message; print "FTP size = \n"; ... (3 Replies)
Discussion started by: FarooqOnline
3 Replies
FTP_CONNECT(3)								 1							    FTP_CONNECT(3)

ftp_connect - Opens an FTP connection

SYNOPSIS
resource ftp_connect (string $host, [int $port = 21], [int $timeout = 90]) DESCRIPTION
ftp_connect(3) opens an FTP connection to the specified $host. PARAMETERS
o $host - The FTP server address. This parameter shouldn't have any trailing slashes and shouldn't be prefixed with ftp://. o $port - This parameter specifies an alternate port to connect to. If it is omitted or set to zero, then the default FTP port, 21, will be used. o $timeout - This parameter specifies the timeout for all subsequent network operations. If omitted, the default value is 90 seconds. The timeout can be changed and queried at any time with ftp_set_option(3) and ftp_get_option(3). RETURN VALUES
Returns a FTP stream on success or FALSE on error. EXAMPLES
Example #1 ftp_connect(3) example <?php $ftp_server = "ftp.example.com"; // set up a connection or die $conn_id = ftp_connect($ftp_server) or die("Couldn't connect to $ftp_server"); ?> SEE ALSO
ftp_close(3), ftp_ssl_connect(3). PHP Documentation Group FTP_CONNECT(3)
All times are GMT -4. The time now is 11:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy