Perl: ERROR in FTP in UNIX

Hi all
I am using this FTP Script

my $envir = $ENV{ECR_ENV};
if ($envir eq 'dev') {
        open FTP, "|ftp -n $ftpHost" or die "Problem with ftp to $ftpHost\n";
        print FTP "user $ftpUser $ftpPass\n";
        print FTP "lcd $archPath \n";
        print FTP "put $outFileName \n";
        print FTP "bye \n";
        close FTP or die "Problem closing ftp connection to $ftpHost";

and the error I am getting is:

Local directory now /apps/XXX/XXX/a/teport
Please login with USER and PASS.
Passive mode refused.  Turning off passive mode.
Please login with USER and PASS.
ftp: bind: Address already in use

---------- Post updated at 08:11 AM ---------- Previous update was at 04:40 AM ----------

Any idea why this is?

Hi,

I notice that you've had no replies to this so I thought that I'd chip in.

Let me say that I don't use Perl but that I have scripted ftp operations many times and have come across login errors quite often.

I usually utilize a .netrc file to automate login to a ftp server without any prompt for userid or password.

Typically the content of .netrc is:-

machine <nodename> login <userid> password <password>

One line in .netrc for each ftp server to be used.

.netrc must be in the home directory of the user under which the command (or script) is running. Access rights must be rw for owner ONLY.

I don't see any reason why a Perl script couldn't utilize a .netrc file since it's the ftp command that looks for it, not Perl.

Hope this helps. Any questions just post reply.

That's Correct, But my question is why this error is coming, whats the reason behind that..

I don't know, but what I do know is that to script any kind of auto-login of ftp seems to be a nightmare in any language. Try searching this forum for stuff like "ftp login", etc, or Google it.

Many people have tried to include a prompting for userid/password in their scripts or providing these as environment variables, and cannot make it work (apart from using ftp's in-built method of .netrc). It just appears to be a damned difficult thing.

The purpose of my post was purely to suggest that this error has less to do with your Perl scripting, and more to do with the ftp command itself.

This might be useful...........

@parthmittal2007 and further to earlier posters.
You have the ftp -n [parameter. This tells ftp that you are using a .netrc file and not logging in from the command line. See man ftp .

Have you tried this ftp manually without the complication of Perl? What is the full dialogue from such a manual session (not just the edited highlights)? This might give us a clue about the remote computer and whether it is actually a ftp server.
The last time I saw that bind error there was a duplicate IP address on the network. If there are Virtual Machines involved in this, please make it clear.

If you can, please post the Operating System and version of BOTH computers concerned. Your lack of basic information in new threads is pathetic after this number of posts.

One tip with ftp scripts is to test your local configuration first by connecting to localhost .