Perl: ERROR in FTP in UNIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl: ERROR in FTP in UNIX
# 1  
Old 08-30-2012
Perl: ERROR in FTP in UNIX

Hi all
I am using this FTP Script
Code:
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:
Code:
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?

Last edited by methyl; 08-30-2012 at 06:13 PM.. Reason: More code tags. Minor grammar corrections for readability
# 2  
Old 08-30-2012
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:-

Code:
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.
# 3  
Old 08-30-2012
That's Correct, But my question is why this error is coming, whats the reason behind that..
# 4  
Old 08-30-2012
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...........

http://www.linuxquestions.org/questi...efused-940344/

http://www.linuxquestions.org/questi...in-use-213509/

Last edited by hicksd8; 08-30-2012 at 04:12 PM..
# 5  
Old 08-30-2012
@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.

Last edited by methyl; 08-30-2012 at 06:15 PM.. Reason: correct some of my grammar and spelling
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. UNIX for Advanced & Expert Users

Unix FTP error

Hai I have made a directory compression using TAR command. the size of the file is 1247388160bytes. when i ftp this file to another server it is throwing error like 200 PORT command successful. 150 Opening ASCII mode data connection for old_versions.tar.gz. netout: Broken... (7 Replies)
Discussion started by: shenthil76
7 Replies

3. Shell Programming and Scripting

FTP From UNIX to WINDOWS Using PERL

Hi All, I have to write a PERL script in which I have to FTP results from UNIX to Windows Desktop. How can I do this using PERL? Thanks (1 Reply)
Discussion started by: kunal1514
1 Replies

4. Shell Programming and Scripting

ftp from windows to unix using a perl script on unix machine

i need to ftp a file from windows to a unix machine by executing a sript(perl/shell/php) from that unix machine.i can also use HTML and javascript to build forms. (3 Replies)
Discussion started by: raksha.s
3 Replies

5. UNIX for Advanced & Expert Users

MVS->Unix FTP : Using chmod as part of FTP.

We are transferring file from mainframes to unix, & in FTP process itself we would like to set access rights for unix machine. Has anyone used chmod command in association with site command in ftp? How it should be used? Thanks in advance. (1 Reply)
Discussion started by: videsh77
1 Replies

6. Shell Programming and Scripting

FTP script to FTP file to UNIX - Solaris

Hello, A couple of times per week, i receive emails notifications when files are available for processing. Currently i read these eamails with a java program and store the attachement on my C: drive and would now like to generate a PC script to send this file name up to UNIX-Solaris and... (3 Replies)
Discussion started by: bobk544
3 Replies

7. Shell Programming and Scripting

FTP script for sending a file from one unix directory to another unix server director

Hi, My local server is :/usr/abcd/ Remote server is :/Usr/host/test/ I want to send files from local unix directory(All files starting with O_999) to remote host unix directory. Can any body give me the Unix Shell script to do this. One more doubt: Shall we need to change the file... (1 Reply)
Discussion started by: raja_1234
1 Replies

8. HP-UX

URGENT: UNIX FTP cannot find path error

Dear all We are currently working on to install some ERP system in wjhich we need to FTP from unix to windows 2000 machine We run ./lodrun to get files from d/xxxxx/xxxx directory but the ftpoutput.log file shows following error FTP: xxxxxxxxx system cannot find the path specified... (1 Reply)
Discussion started by: minix
1 Replies

9. UNIX for Advanced & Expert Users

FTP - Sco Unix to ProFTPD Error

First off I did try google for help on this topic, didn't really find anything. When I try to ftp from my SCO Unix box (SCO_SV servername 3.2 5.0.5 i386) to a proFTPD server within my company I get this error Connected to 10.?.?.?. 220 ProFTPD Server ftp.hostname.com Name (10.?.?.?:root):... (1 Reply)
Discussion started by: whegra
1 Replies

10. UNIX for Advanced & Expert Users

unix ftp error msg help

we have two alpha stations which are connected on two sides on the same wan (64k leased line), here is one problem described as follow. when i do a ftp to copy a file form one to another, an error mesg shown and the file lenth is 0 at last. diamond> ftp 192.168.50.1 Connected to... (1 Reply)
Discussion started by: royxiao
1 Replies
Login or Register to Ask a Question