I am trying to use Jsch Sftp Channel to upload a file to an IBM Mainframe, and the directory has to be "//", where the mainframe will automatically route the file where it needs to go.
In an sftp command session on the IBM mainframe, I can do this:
sftp [email protected]
connecting to 1.2.3.4...
[email protected]'s password:
sftp> pwd
Remote working directory: /users/home/myuser
sftp> cd //
sftp> pwd
Remote working directory: //
sftp> put "#12345.abcdef.xxx.xxx"
uploading #12345.abcdef.xxx.xxx to //#12345.abcdef.xxx.xxx
#12345.abcdef.xxx.xxx 100% 403 0.4KB/s 00:00
So I created a JSch sftp session (version 0.1.5.1) to attempt the same upload, but it does not work:
JSch jsch = new JSch();
Session session = jsch.getSession("myuser", "1.2.3.4");
session.setPassword("mypass");
session.connect();
Channel channel = session.openChannel("sftp");
channel.connect();
ChannelSftp sftp = (ChannelSftp)channel;
log.info(" user home pwd " + sftp.pwd()); //prints /users/home/myuser
sftp.cd("//")
log.info(" pwd after cd " + sftp.pwd()); //only prints /
sftp.put(filename); //get sftp error, no such file
So I cannot get to that // structure through the JSch library. Is there a certain mode or flag that needs to be set for the sftp session to know it's on a mainframe?
I have no issue at all doing a JSch sftp session to my /users/home/myuser directory, just can't get it to go to the //
filename
? Anyway, don't you have a bunch of technical support people you can ask? People at your site who've done the same thing? A program spec? – Bill Woodger//#12345.abcdef.xxx.xxx
instead ofcd
-ing to your z/OS filesystem? – piet.tmv ./SMPL.DATA "//'SMPL.DATA'"
is what finally worked in the JSch exec channel – Dio H