LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-29-2004, 02:36 PM   #1
mairot
LQ Newbie
 
Registered: Nov 2004
Posts: 6

Rep: Reputation: 0
how to set passive mode off in perl!!


I'm using Redhat8 to collect files with a perl script (not web) across a firewal. In redhat8 passive mode is set by default. I want to set it to off.
How to do so?

Since it set to on, i'm not able to get a listing of the directory i'm supposed to find files..

ex : ftp> ls
227 Entering Passive Mode (xx,xx,xx,xx,10,38)
ftp: connect: Connection refused

Thanks!
 
Old 11-29-2004, 03:03 PM   #2
sigsegv
Senior Member
 
Registered: Nov 2004
Location: Third rock from the Sun
Distribution: NetBSD-2, FreeBSD-5.4, OpenBSD-3.[67], RHEL[34], OSX 10.4.1
Posts: 1,197

Rep: Reputation: 47
I don't have a RH8, but if it uses the same ftp program FC2 uses, there is no way to disable it's use of passive at command invocation. You could put pass in the list of commands to be run, or you could do it the "right way"
 
Old 11-29-2004, 03:18 PM   #3
mairot
LQ Newbie
 
Registered: Nov 2004
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks...

but i can't do it the right way because i only know the prefix of the file... So i must do a "ls" to check wich files i have to download.

It's a program that download a file each 15 minutes...

On redhat6 passive mode is set to off but on redhat8 not...

May be i can downgrade to RH6 but it's not possible...


i'm still stuck....

There must be a way ta have a ls working...??!
 
Old 11-29-2004, 03:58 PM   #4
sigsegv
Senior Member
 
Registered: Nov 2004
Location: Third rock from the Sun
Distribution: NetBSD-2, FreeBSD-5.4, OpenBSD-3.[67], RHEL[34], OSX 10.4.1
Posts: 1,197

Rep: Reputation: 47
No, no need to downgrade. After you have the connection set up, just turn passive off. Something like this *should* work:

Code:
ftp blah.com << !EOF!
username foo
password bar
pass
ls /path
get blah.txt
bye
!EOF!
Also, if this is on servers you control, rsync is your friend
 
Old 11-29-2004, 04:49 PM   #5
mairot
LQ Newbie
 
Registered: Nov 2004
Posts: 6

Original Poster
Rep: Reputation: 0
Manually it's working... Via perl FTP it's not working!

Somewhere a pasv command is send...
 
Old 11-29-2004, 04:53 PM   #6
sigsegv
Senior Member
 
Registered: Nov 2004
Location: Third rock from the Sun
Distribution: NetBSD-2, FreeBSD-5.4, OpenBSD-3.[67], RHEL[34], OSX 10.4.1
Posts: 1,197

Rep: Reputation: 47
Post the code block that does the FTP transfer (remove any sensitive info such as IPs or username:password)
 
Old 11-30-2004, 08:24 AM   #7
mairot
LQ Newbie
 
Registered: Nov 2004
Posts: 6

Original Poster
Rep: Reputation: 0
#!/usr/bin/perl
my $ftp;
use strict;
use Net::FTP;
main();
sub main
{
$ftp = Net::FTP->new("IP outside the firewal",'Debug',1);
$ftp->login("user","password");
$ftp->binary();
$ftp->cwd("/the/directory");
my @ftp_resp = $ftp->dir("dcol-mmsc1be2_20041129205929Z*");
print ($#ftp_resp);
}

This is the "Debug" output

1 ) Net::FTP: Net::FTP(2.65)
2 ) Net::FTP: Exporter(5.567)
3 ) Net::FTP: Net::Cmd(2.21)
4 ) Net::FTP: IO::Socket::INET(1.26)
5 ) Net::FTP: IO::Socket(1.27)
6 ) Net::FTP: IO::Handle(1.21)

7 ) Net::FTP=GLOB(0x8065878)<<< 220 mmsc1ms1 FTP server (Compaq Tru64 UNIX Version 5.60) ready.
8 ) Net::FTP=GLOB(0x8065878)>>> user MCellFTP
9 ) Net::FTP=GLOB(0x8065878)<<< 331 Password required for MCellFTP.
10) Net::FTP=GLOB(0x8065878)>>> PASS ....
11) Net::FTP=GLOB(0x8065878)<<< 230 User MCellFTP logged in.
12) Net::FTP=GLOB(0x8065878)>>> TYPE I
13) Net::FTP=GLOB(0x8065878)<<< 200 Type set to I.
14) Net::FTP=GLOB(0x8065878)>>> CWD /usr/users/MCellFTP/sdr_collected
15) Net::FTP=GLOB(0x8065878)<<< 250 CWD command successful.
16) Net::FTP=GLOB(0x8065878)>>> PASV
17) Net::FTP=GLOB(0x8065878)<<< 227 Entering Passive Mode (xx,xx,xx,xx,12,72)

18) Net::FTP=GLOB(0x8065878)>>> LIST dcol-mmsc1be2_20041129205929Z*

-1

Line 16-17 passive mode sent by ??? and the response from the server. This is what i do not want to be sent by my Redhat8 perl librairies...

Thanks!
 
Old 11-30-2004, 10:02 AM   #8
mairot
LQ Newbie
 
Registered: Nov 2004
Posts: 6

Original Poster
Rep: Reputation: 0
Got it!

Thanks for your help.

Need to set FTP_PASSIVE to 0 in my perl script.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ProFTPd, Redhat 8.0 and passive mode Slasher Linux - Networking 10 05-09-2008 04:08 PM
proftpd, passive mode, and a router.... apberzerk Linux - Networking 2 07-11-2004 07:05 PM
vsftp passive mode breaking bluethundr Linux - Networking 2 02-24-2004 07:13 AM
ftp passive mode ? lenlutz Linux - Networking 1 11-05-2003 01:11 PM
kermit in passive mode? bbeers Linux - Software 1 08-23-2002 07:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration