Page 1 of 1

PHP to FTP JCL to MainFrame?

Posted: Thu Mar 25, 2004 6:55 pm
by rxsid
Hi all,

Trying to FTP some JCL to a mainframe from a winNT box using PHP 4.3.1.
I can successfully open a cmd prompt, ftp the commands and the JCL file up and have the m/f run the jcl.

I can't get my php script to send the jcl. The ftp_site doesn't seem to be mimicking ftp commands. I can't use ftp_raw cause I can't load 5.0 right now.

Code: Select all

$ftp_server = "mainframeDNS";

$ftp_user = "userid";
$ftp_pass = "password";

$conn_id = ftp_connect($ftp_server) or die (writeError($logsPath,$errorLog, $gmtDate."\r\n FTP ERROR>> " . $conn_id . "\r\nCould Not Establish FTP Connection to ".$ftp_server.".\r\n\r\n",$rptName,$univDate));

// try to login
if (!ftp_login($conn_id, $ftp_user, $ftp_pass)) {
    writeError($logsPath,$errorLog, $gmtDate."\r\n FTP ERROR>> " . $conn_id . "\r\nCould Not Log On To FTP Connection using ".$ftp_user.".\r\n\r\n",$rptName,$univDate);
}
ftp_site($conn_id, 'ascii') or die ("ERROR FTP SITE 1");
ftp_site($conn_id, 'quote site filetype=jes') or die ("ERROR FTP SITE 2");
ftp_site($conn_id, 'put C:\\Reports\\scripts\\cpo070jcl.txt') or die ("ERROR FTP SITE 3"); //cpo070jcl.txt contains valid MVS jcl.


//ftp_put($conn_id, "C:\\Reports\\scripts\\cpo070jcl.txt", FTP_ASCII) or die ("ERROR FTP PUT");  //This one requires 4 parms, including a mainframe file name...which isn't what i need..i'm not storing a file...just trying to send the jcl to the jes reader.
ftp_quit($conn_id);
Any ideas on a work around? How could I open the windows command prompt and send it (win cmd prompt) the commands?

Thanks in advance.

Posted: Thu Mar 25, 2004 9:19 pm
by Stoker
use perl? :)

FTP is a really simple protocol, you could just use sockets?

Posted: Mon Mar 29, 2004 12:55 pm
by rxsid
Thanks Stoker for the reply!

Yeah...i would use PERL (I know it better than PHP), but PERL isn't installed on that box...and I probably couldn't get management to allow me to put it on there for only this reason.

Anyway....

I figured it out with a different approach:

Code: Select all

system("FTP -s:c:\\Reports\\scripts\\FTPputFile.txt\n");
On the win NT box...that opens a command line screen, starts FTP and reads in line by line the ftp commands found in FTPputFile.txt which contain:

Code: Select all

open mainframeDNS
userid
pass
ascii
quote site filetype=jes
put cpo070jcl.txt
quit
works like a charm!!