Why do I get different results with Command Prompt compared with using Process

robertb_NZ

Well-known member
Joined
May 11, 2010
Messages
146
Location
Auckland, New Zealand
Programming Experience
10+
When I enter this command into the command prompt: -
FTP -d -s:c:\jzftpin.txt >jzftpout.txt
then FTP works perfectly, using the instructions that I pre-defined in the file C:\jzftpin.txt, and returning these results in jzftpout.txt: -
ftp> Connected to 192.86.32.59.
Open 192.86.32.59
220-FTPSERVE IBM FTP CS V2R1 at S0W1.DAL-EBIS.IHOST.COM, 01:52:43 on 2014-07-25.
220 Connection will close if idle for more than 5 minutes.
User (192.86.32.59:(none)):
331 Send password please.

230 IBMUSER is logged on. Working directory is "IBMUSER.".
ftp> Quote Site Filetype=JES
200 SITE command was accepted
ftp> Put C:\CRDTA1.JCL
200 Port request OK.
125 Sending Job to JES internal reader FIXrecfm 80
250-It is known to JES as JOB00442
250 Transfer completed successfully.
ftp: 14890 bytes sent in Seconds Kbytes/sec.
ftp> 1.4310.41Quit
221 Quit command received. Goodbye.

I'm trying to automate this using the following code (suggested by jmcilhinney - hopefully he'll reply): -
Dim myprocess As New Process
Dim StartInfo As New System.Diagnostics.ProcessStartInfo
StartInfo.FileName = "cmd" 'starts cmd window
StartInfo.RedirectStandardInput = True
StartInfo.RedirectStandardOutput = True
StartInfo.UseShellExecute = False 'required to redirect
StartInfo.CreateNoWindow = True 'creates no cmd window
myprocess.StartInfo = StartInfo
myprocess.Start()
Dim SR As System.IO.StreamReader = myprocess.StandardOutput
Dim SW As System.IO.StreamWriter = myprocess.StandardInput
Dim Command As String = "FTP -d -s:JZFTPIN.TXT >JZFTPOUT.TXT"
SW.WriteLine(Command) 'the command you wish to run.....
SW.WriteLine("exit") 'exits command prompt window
SW.Close()
SR.Close()​

Now however JZFTPOUT.TXT contains
User (192.86.32.59:(none)): Open 192.86.32.59
--->
USER IBMUser
--->
PASS ********
---> Quote Site Filetype=JES
Site Filetype=JES
---> PUT C:\crdta1.jcl
PORT 192,168,1,101,197,117
---> STOR CRDta1.JCL
---> Quit
QUIT

Why the difference? How do I get the FTP messages as in the Command Prompt example back to my program?

In both cases the FTP actually worked perfectly.

Any help gratefully accepted. I can't see anything in the MSDN documentation of the Process command that suggests what I'm doing wrong.

This is part of http://www.vbdotnetforums.com/vb-ne...p-ibm-mainframe-including-job-submission.html. Hopefully a reply here will close both queries.
 
I will take a closer look at this if and when I get the chance but, to be honest, I've never done this sort of thing myself. I've never actually used that code that I recommended to you myself; I just knew it was there and others had had success with it. I've also never FTPed from a command prompt so I'm very much in the dark here.
 
If you can find out anything useful I'd be very grateful. This whole problem of FTPing to/from mainframes is proving inordinately difficult. If you want to actually experiment with mainframe FTPing then let me know and I'll send you a private message to give you access to my virtual mainframe, we'll need to schedule this as the VM is usually inactive. However I doubt that you will need this (even if you wanted to experience the hair-shirt and flagellation of working with a mainframe :)) as I'm sure that this is problem needs to be solved on the Microsoft side.

I'd really like to use something like WebFTPRequest as this command line approach feels to me like a dreadful hack, but it seems to be the only way forward.

Thank you, Robert.
 
Back
Top