jsch

Java Redirecting Input and Output Stream of Terminal to GUI (JSch)

别说谁变了你拦得住时间么 提交于 2019-12-08 07:47:13
问题 I'm working on a project in which I intend to make a Java GUI application that connects to a ssh server and executes remote commands on the server. I'm willing to use JSch Library. My aim is to make buttons and textfields those will provide the user the ability of sending commands and getting replies easily. I mean, instead of opening xShell and prompting "grep "hi" /usr/file.txt", the user will choose the path from the list and will enter "hi" into the textfield and will press the button for

sending SIGINT CTRL-C using ganymed SSH2?

≯℡__Kan透↙ 提交于 2019-12-08 07:37:43
问题 I need to kill a process that I have started using ganymed SSH2. Specifically I would like to gracefully kill it using Ctrl + C . I have seen ideas of trying to send ASCII \x03 but when using the execCommand() it wont take escaped chars. How can I send Ctrl + C SIGINT through ganymed? If there is another Java SSH app I should be using let me know, I have looked into Jsch, sshj but just found ganymed ssh2 to the be easiest. The program i am trying to kill is tethereal (wireshark) 回答1: I've

“Received message is too long” when connecting using Ant/JSch to SFTP server

与世无争的帅哥 提交于 2019-12-08 06:52:45
问题 I would like to upload a file from my local unix machine to a remote server that supports SFTP. I tried to implement using Ant script that used SCP task with sftp attribute set to true, but it didn't work, since it would always error out: com.jcraft.jsch.JSchException: 4: Received message is too long: 1416128878. If you can help me achieve that using shell script that should resolve the issue. Also will I have to install sftp or something on my local machine so that the script works? Any help

Copying files internally on an SFTP server using Spring integration/JCraft JSch

橙三吉。 提交于 2019-12-08 06:36:15
问题 I was wondering if there is a way to copy files on an SFTP server to another directory on the same SFTP server. I want to do this without getting the file in a client and then setting it in the other folder. Of course this would work fine but I guess that this would produce more overhead, so I would like to avoid this if at all possible. I'm currently working with Spring integration which is based on JCraft JSch. So far I haven't been able to find any way to do this without an intermediary.

Shell ping command with source option is failing when executed using JSch setCommand

别来无恙 提交于 2019-12-08 06:35:24
问题 I'm testing short ping test program. If I set simple ping command, "ping y.y.y.y -c 5 -s 500 " into setCommand() function, it works as designed. But if I add addition ping options, "ping source x.x.x.x host y.y.y.y -c 5 -s 500" , I got ping: unknown host source message back. If I manually execute both commands from the x-terminal, the both commands works fine. I need to make the program to ping from different source interface IPs. What is the difference between two commands using JSch

Resume file transfer for a half way failed file transfer

半腔热情 提交于 2019-12-08 05:09:28
I am using this jsch library ( http://www.jcraft.com/jsch/ )in my ColdFusion application. My application wants to implement a retry mechanism - if a file transfer fails half way through then I want to resume (or continue) the file transfer from where it left off. Is this possible to achieve using this jsch library? Just reconnect and start an upload again with RESUME flag: channelSftp.put(src, dst, ChannelSftp.RESUME); The RESUME flag will make JSch query size of a partial remote file and restart the transfer from there. If the file is already uploaded completely, it transfers nothing. 来源:

File/Directory synchronization in Java using JSch?

邮差的信 提交于 2019-12-08 04:28:13
问题 Is it possible to do file/directory sync in Java using JSch ? I need to sync directory from a remote linux machine to my local windows machine. Is this possible ? -Tivakar 回答1: The easiest way to download files from SCP server is using Commons VFS along with JSch: import java.io.*; import org.apache.commons.io.FileUtils; import org.apache.commons.vfs2.*; public class CopyRemoteFile { public static void copyRemoteFiles(String host, String user, String remotePath, String localPath) throws

Scp file with jsch gives 'unexpected filename'

你。 提交于 2019-12-08 04:21:43
问题 I'm using Jsch 0.1.44 to scp a file from one host to another. The relevant code is the following: public boolean transferFileToHost(File fileToTransfer, String destDirectory, String destFilename) { Channel channel = null; try { String command = "scp -t "+ destDirectory + destFilename; channel = session.openChannel("exec"); ((ChannelExec)channel).setCommand(command); OutputStream out = channel.getOutputStream(); InputStream in = channel.getInputStream(); if(!connectToChannel(channel, in)) {

Downloading file from SFTP directly to HTTP response without using intermediate file

半城伤御伤魂 提交于 2019-12-08 04:08:54
问题 I am trying to download a file through SFTP using Java JSsch library. I am successful in downloading the file to a local directory. **But, all I need is to download the file directly to browser without giving any local destination path (like how file gets downloaded in Chrome). I am using Spring controller AngularJS Promise to catch the response. Below is my code. @RequestMapping(value = "/downloadAttachment", method = RequestMethod.POST, produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)

How to detect error (as in “Directory not found”, “TNS listener lost contact”, etc) in JSch?

与世无争的帅哥 提交于 2019-12-08 03:42:28
I need to get error message while firing any command using JSch. Currently I am using below code to get output of tail command, but if the file does not exist, I should get the error as output (which I am not getting). public String getOutput() { LOGGER.debug("[getOutput]"); StringBuffer output = new StringBuffer(); InputStream in = null; if (channel != null && channel.isConnected()) { try { in = channel.getInputStream(); byte[] tmp = new byte[1024]; while (true) { LOGGER.debug("[getOutput] in while"); while (in.available() > 0) { LOGGER.debug(in.available()); int i = in.read(tmp, 0, 1024); if