jsch


JSCH read from input stream hangs from time to time


I'm using jsch-0.1.53.
In order to execute a command and return it's output, I wrote the next block of code:
#Override
public String executeAndGetOutput(CheckPointSSHConnection connection, String command) throws IOException , JSchException{
logger.debug("Executing command \"" + command + "\"");
StringBuilder retVal = new StringBuilder();
ChannelExec channel = null;
InputStream in=null;
InputStream errStream=null;
try {
Session session = connection.getSession();
channel = (ChannelExec) session.openChannel("exec");//only shell
in = channel.getInputStream();
errStream = channel.getErrStream();
channel.setCommand(command);
channel.connect(10000);
String errInStr = StringUtils.toString(errStream);
String inStr = StringUtils.toString(in);
return inStr+errInStr;
} finally {
IOUtils.close(in);
IOUtils.close(errStream);
if (channel != null) {
try {
channel.disconnect();
} catch (Throwable throwable) {
logger.warn("An exception occured while trying to close ssh chanel. Message:",
throwable.getMessage());
}
}
}
}
The problem is that from time to time, reading the errStream just hangs and blocking the thread.
Can someone please tell me what I'm doing wrong?
The command that I'm executing is load_indicators --add -a detect -i /tmp/sample_file.csv , it's Checkpoint CLI

Related Links

How to interact with the script after its execution using Jsch
java jsch -executing multiple unix commands
How to get one stream from error stream and input stream when calling a script using JSCH
SFTP using jschexception verify false sometimes fails
how to increase the jsch buffer size?
The cipher 'aes256-cbc' is required, but it is not available
How to pause/resume procedure while/after upload file by ChannelSftp
jsch + running multiple command in shell after SU and then close channal
NGit/Nsch Generating SSH Keypair (c# Jgit)
Extract userInfo from JSCH stream
Running a Shell Script using java ( process Builder ) with a specific unix user
Java jsch and resuming file upload after interruption?
How to pass a variable through channel in Jsch?
How to handle passwords prompts in expectj
Retaining the last modified date while using ChannelSftp for file transfer
Is there a limit to how many channels can be open per session in JSch?

Categories

HOME
cloud
debugging
zeromq
tinymce
nullpointerexception
angular-material
cvs
at-command
umd
icloud
yum
enterprise-library-5
applepay
here-api
midi
spring-xd
modelica
export-to-csv
collectd
size
dtrace
windows-server-2012
circuit
vaadin7
windows-7-x64
django-cms
google-pagespeed
swingx
riot.js
google-search-api
core-text
crystal-reports-2010
xpages-ssjs
buildbot
django-storage
dynamic-featured-image
user-interaction
phpfox
elasticsearch-net
delicious-api
tinymce-4
key-value-observing
phonegap
pim
stringtemplate
mozilla
bytecode-manipulation
adobe-premiere
gesture
streamsets
objectlistview
angularjs-factory
unoconv
sfdc
botbuilder
ibpy
firebase-admin
nxlog
fakeiteasy
no-www
parentheses
clean-architecture
blogengine.net
setter
nodebb
memory-alignment
smart-table
abcpdf9
android-fonts
login-control
ctest
fuzzy-search
contact-list
fputcsv
simplewebrtc
javax.sound.midi
jms2
comobject
atk4
tmuxinator
purge
browser-bugs
census
clipperlib
codeigniter-url
jquery-layout
ms-project-server-2010
soundtouch
opcache
mylyn
ember-app-kit
drools-planner
jquery-knob
funscript
bluepill
dbproviderfactories
regsvr32
data-loss
blackberry-playbook
coredump
appendto
winbugs14
celltable
subviews
coda-slider
sortable-tables
gallio
dbal
vc90
firefox-5
audio-capture
backcolor
uimenucontroller
pascal-fc
spec#
zune
grid-system

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App