robertb_NZ
Well-known member
I am trying to implement FTP to/from a zOS mainframe. My current code is below: this seems to transfer the data to the mainframe perfectly except that the results are gibberish, presumably because the data hasn't been converted from Unicode to EBCDIC. How do I do this?
The source file (path\TEST1.JCL, on my laptop) has data: -
//IBMUSERF JOB ,CLASS=A,MSGCLASS=H,NOTIFY=&SYSUID,COND=(8,LT)
//*** COPY SOURCE INTO SOURCE LIBRARY
//* Dummy Data for initial FTP test
After this has been FTP'd to the zOS system it looks like this: -
??(????? ?|? ?< ?? (???< ?? ? +|???? ?????? ?|+? <? ?
?? ?+?| ?|???? <??? ?? ??__` ?/?/ ??? ?>???/% ??& ????
(which replaced the previous contents, so I know that something has been transferred).
Here is my code: -
Dim JCLFile As String = My.Settings.UserCommonPath & "\" & My.Settings.Programs & "\TEST1.JCL"
Try
Dim FTPServer As String = "FTP://" & My.Settings.SubmitIP & ":" & My.Settings.SubmitPort & "/"
Dim TargetFile As String = "'IBMUSER.MANAJAZZ.SRCLIB(TEST1)'"
Dim FTPTarget As String = FTPServer & TargetFile
Dim Request As System.Net.FtpWebRequest =
DirectCast(System.Net.WebRequest.Create(FTPTarget), System.Net.FtpWebRequest)
Request.Credentials = New System.Net.NetworkCredential(My.Settings.Userid, My.Settings.Password)
Request.Method = System.Net.WebRequestMethods.Ftp.UploadFile
' read in file...
Dim bFile() As Byte = System.IO.File.ReadAllBytes(JCLFile) '<= Source file: see JCLFile above
' upload file...
Dim clsStream As System.IO.Stream = Request.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
Catch ex As Exception
MsgBox("Error with FTP:" & ex.Message)
End Try
Thank you for any feedback,
Regards, Robert.
The source file (path\TEST1.JCL, on my laptop) has data: -
//IBMUSERF JOB ,CLASS=A,MSGCLASS=H,NOTIFY=&SYSUID,COND=(8,LT)
//*** COPY SOURCE INTO SOURCE LIBRARY
//* Dummy Data for initial FTP test
After this has been FTP'd to the zOS system it looks like this: -
??(????? ?|? ?< ?? (???< ?? ? +|???? ?????? ?|+? <? ?
?? ?+?| ?|???? <??? ?? ??__` ?/?/ ??? ?>???/% ??& ????
(which replaced the previous contents, so I know that something has been transferred).
Here is my code: -
Dim JCLFile As String = My.Settings.UserCommonPath & "\" & My.Settings.Programs & "\TEST1.JCL"
Try
Dim FTPServer As String = "FTP://" & My.Settings.SubmitIP & ":" & My.Settings.SubmitPort & "/"
Dim TargetFile As String = "'IBMUSER.MANAJAZZ.SRCLIB(TEST1)'"
Dim FTPTarget As String = FTPServer & TargetFile
Dim Request As System.Net.FtpWebRequest =
DirectCast(System.Net.WebRequest.Create(FTPTarget), System.Net.FtpWebRequest)
Request.Credentials = New System.Net.NetworkCredential(My.Settings.Userid, My.Settings.Password)
Request.Method = System.Net.WebRequestMethods.Ftp.UploadFile
' read in file...
Dim bFile() As Byte = System.IO.File.ReadAllBytes(JCLFile) '<= Source file: see JCLFile above
' upload file...
Dim clsStream As System.IO.Stream = Request.GetRequestStream()
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
Catch ex As Exception
MsgBox("Error with FTP:" & ex.Message)
End Try
Thank you for any feedback,
Regards, Robert.