Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP GET for files from mainframes using perl

Status
Not open for further replies.

himagauri

Programmer
Jun 29, 2006
10
US
I'm trying to do an FTP GET a file from mainframe to Linux.
I have a perl daemon on Linux which issues the follwing commands-

my $ftp=Net::FTP->new($MVSADDR,Timeout=>1800,Debug=>1);

my $olddir = getcwd();
chdir(makedir()) or $ftp=0;

$ftp->login($MVSUSER,$MVSPASS);

$ftp->binary;
$ftp->pasv();

$ftp->get(remote file,localfile);

$ftp->quit;


and I get the follwing messages from FTP server:

220-FTPD1 IBM FTP CS V1R7 at IMSJES2.us.rxcorp.com, 21:48:41 on 2006-06-29.
220 Connection will close if idle for more than 15 minutes.
user xxxxxxx
331 Send password please.
PASS ....
230 xxxxxxx is logged on. Working directory is "xxxxxxx.".
TYPE I
200 Representation type is Image
PASV
227 Entering Passive Mode (162,44,231,228,7,34)
PORT 162,44,231,235,159,195
200 Port request OK.
RETR 'G1ZIP01.TST.ET770056.FILE001.SPLIT001'
125 Sending data set G1ZIP01.TST.ET770056.FILE001.SPLIT001
250 Transfer completed successfully.

QUIT
221 Quit command received. Goodbye.

The above script downloads a file of 200 bytes correctly.

However a 50 MB or more file is downloaded as a zero byte file and a successful transfer message is received.

When I manually try to do the ftp for 300 MB file, it downloads correctly in 40 seconds.

Why does the script download a zero byte file?
What do I need to do to have the complete file transferred correctly-whatever the size!!

-Please help.

-Thanks,
Regards,
Gauri
 
It has to do with the lrecl and block size.

You have to set these with recfm also, with the quot command.
 
could you give me an example of the quote command and how it is used in this context?

-Thanks,
Gauri
 
Code:
 $ftp->quot("site recfm=fb blksize=23456 lrecl=32 unit=workda")||die("quot command failed: $!");

This has to match the parms with which the file was created.

Also if you get binary, then you will have a EBCDIC file, ASCII will convert it.
 
Hey cdlvj,

I tried the solution you suggested-but I still get a zero byte file...

Could you suggest something more?

-Thanks,
 
I suggest to use simple bash script for this purpose.

#! /bin/sh
#
# Script starts here
#
ftp -n -v <ip-addr> << !EOF
user <username> <password>
bin
hash
get filename
bye
!EOF
#
# Script ends here
#
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top