I am trying to upload a file to a mainframe and allocate the dataset first executing a remote command: ls /+recfm=vb,lrecl=124,blksize=0,space=cyl.25.10
A straight ls / command works and pulls the directory contents of where I login, so I know that the remote command is being sent.
The response I get from the mainframe is:
ls: FSUM6785 File or directory "/+recfm=vb,lrecl=124,blksize=0,space=cyl.25.10" is not found
Any assistance is greatly appreciated.
Code is below.
Try
channel = sftp.Session.OpenSession()
channel.RequestExec(RemoteCommand)
''# receive all response
Dim response As New StringBuilder()
Dim buffer As Byte() = New Byte(4095) {}
While channel.State = SshChannelState.Connected
If Not channel.Poll(sftp.Timeout * 1000, SocketSelectMode.SelectRead) Then
Exit While
End If
Dim n As Integer = channel.Receive(buffer, 0, buffer.Length)
LogIt("Channel Receive: " & n, False, False, "", "")
response.Append(Encoding.[Default].GetString(buffer, 0, n))
LogIt("Response: " & response.ToString, False, False, "", "")
End While
LogIt(response.ToString().TrimEnd(), False, False, "", "")
Catch ex As Exception
LogIt("error: " & ex.Message, False, False, "", "")
Finally
If channel IsNot Nothing Then
LogIt("Closing Channel for Remote Command", False, False, "", "")
channel.Close()
End If
sftp.PutFile(LocalPath & LocalFileName, RemoteDir & RemoteFileName)
End Try