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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ftp mvs

Status
Not open for further replies.

rozzay

Programmer
Jan 3, 2002
142
US
Hi! I am trying to ftp a file to the mainframe using perl and once i have ftp the file i would then like to kick off a job or jcl. When trying to kicking off the jcl or job i would get an error message of 'unable to close datastream' am i missing something in particular?

use Net::FTP;
my $ftp;
$ftp = Net::FTP->new("mainframe.com") || ((print LOG "$now->ERROR:FTP CONNECT TO MF FAILED\n"), return(1));
$ftp->login("userid", "password") || ((print LOG "$now->ERROR:FTP LOGIN TO MF FAILED\n"), return (1));
$ftp->site ("UNIT=PRODB") || ((print LOG "$now->ERROR:FTP SITE PRODB FAILED\n"), return (1));
$ftp->site ($recform) || ((print LOG "$now->ERROR:FTP SITE REC FORM FAILED\n"), return (1));
$ftp->site ($reclen) || ((print LOG "$now->ERROR:FTP SITE REC LENGTH FAILED\n"), return (1));
$ftp ->put($filename, $mainframe_filename) || ((print LOG "$now->ERROR:FTP PUT TO MF FAILED\n"), return (1));
$ftp->site ("filetype=jes") || ((print LOG "$now->ERROR:FTP SITE FILETYPE=JES FAILED\n"), return (1));
$ftp->get($jobname) || ((print LOG "$now->ERROR:FTP GET JOBNAME FAILED\n"), return (1));
 
Perhaps you have to quit the FTP session then run your job?

ftp->quit();

Just a guess...
 
i do apologize i did not include the last line of the script i do initiate a quit right after the get statement.

$ftp->quit();
 
Yup, I tried the script manually ftp and was able to put the file and then kick off the job. Also I noticed when running the script although the error message comes up the file does get ftp to the mainframe and job kicks off but for some reason return code is not 0 for success so i have a error handling when ftp return code is not 0 it would sleep and try ftp the file again. so at the end the file is ftp to the mainframe twice and the job gets kicked off twice.
 
Is it a timing problem? I mean, does the put block until the whole file has been transferred? Also, has the FTP process freed up the file by the time the job runs? Try putting a delay in between the put and the get, just to see what happens.

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top