Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
494 views
in Technique[技术] by (71.8m points)

java - Can JSch SFTP support site commands like lrecl or blksize

I'm trying to figure out whether Jsch sftp framework can support site commands like lrecl, blksize, mgtmclass and so on when trying to SFTP to a mainframe (zos) environment from a non-mainframe environment.

From what I've run across so far it would appear that SFTP specification does not directly support the site command, but I was not 100% sure if that information was accurate.

In researching the JSch more it appears there is a ChannelExec class that appears to be able to execute commands remotely, but whether that will meet my needs here I have not been able to determine as well.

I've also been told by a peer who specializes in mainframe that there is the ability to use some mainframe magic with ls /+/ but how that potentially could be applied to any of the classes available in JSch is beyond him since Java is not his area of expertise.

Any help here would be greatly appreciated.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I am in part going to answer my own question which I was not expecting to do. I ran across, after lots of searching, a piece of code that is exactly what I needed.

So this uses that mainframe magic my peer was talking about to pass the site commands using the ls command.

I am just taking a small excerpt that shows what I was trying to accomplish here:

String lrecl = "/+/lrecl=128"
JSch jsch = new JSch();
Session session = jsch.getSession(user, hostName, port);
session.setPassword(password);
session.connect(120000);
ChannelSftp channel = (ChannelSftp)session.openChannel("sftp");
channel.connect(100000);
channel.ls(lrecl);

This was only part of the code but does show how a site command can be passed. I have not confirmed if all site commands can be sent this way or not.

Hope this helps or saves someone some time.

Any feed back or thoughts on this approach please let me know.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...