jsch


java jsch -executing multiple unix commands


Channel channel=session.openChannel("exec");
((ChannelExec)channel).setCommand("cd ../ && pwd && ls");
channel.connect();
channel.run();
Here how can i use the above code if my commands are from command line arguments or if they are stored in variable like cmd1 ,cmd2 etc
i tried
((ChannelExec)channel).setCommand("cmd1 && cmd2 && cmd3");
variable substitution is not happening. Please help me on this
Thanks,
Prashanth
The variables need to be specified outside of the String itself rather than being part of a String
((ChannelExec)channel).setCommand(cmd1 + " && " + cmd2 " + " && " + cmd3);

Related Links

What the situation will make channel.getExitStatus() return 1
JSch read local log file
JSCH setCommand is not working
com.jcraft.jsch.JSchException: SSH_MSG_DISCONNECT: 11 No appropriate prime between 1024 and 1024 is available. en
I'm trying to use Jsch to establish an SSH connection in Java.I got the Exception com.jcraft.jsch.jschexception unknownhostkey
com.jcraft.jsch.JSchException: failed to send sftp request
JSch for pbrun not working
JSCH read from input stream hangs from time to time
Hundreds of Apache SSHD clients leave hundreds of OpenSSH daemon processes running
Jsch - ssh connection through ssh tunnel
Changing password using Jsch and ChannelExec
how to delete local file using jsch after file is sent to remote SFTP server directory
com.jcraft.jsch.JSchException: Auth fail error
Creating a new file in SSH enabled system using JSCH
How to interact with the script after its execution using Jsch
java jsch -executing multiple unix commands

Categories

HOME
xamarin
google-chrome-extension
clips
webpack
image-processing
deezer
single-sign-on
relative-path
view
filtering
umd
google-project-tango
esper
primary-key
ssl-client-authentication
volttron
size
static-libraries
visual-studio-2005
zebra-printers
quickfix
quartz-scheduler
netflix
dosgi
fatal-error
ef-migrations
sms-gateway
openedx
django-cms
nodatime
jtextfield
zapier
extjs5
pass-by-reference
sparse-matrix
fopen
sql-server-2012-express
media-queries
google-cloud-endpoints-v2
semantic-versioning
perlin-noise
wpf-controls
overriding
jmonkeyengine
theano.scan
awt
janrain
total-commander
s
jlink
alphabet
aurelia-validation
colorama
directory-structure
magma
spring-cache
merge-conflict-resolution
fputcsv
lttng
nsviewcontroller
pagedlist
sigabrt
actionbardrawertoggle
php-parse-error
ptrace
associative-array
system.management
cloudbees
retina
coveralls
embedded-code
0xdbe
tableau-online
responsive-images
microbenchmark
event-bubbling
processmodel
oberon
p2
dereference
kineticjs
oxwall
phalanger
socketexception
bitcoinj
article
jubula
valueconverter
datagridviewcolumn
hyprlinkr
oracle-warehouse-builder
flexmojos
gnu-smalltalk
pyhdf
floating-point-precision
ftps
jplaton
back-stack
sqlperformance
android-hardware
unc
gdata-api
dbproviderfactories
ticoredatasync
stage
xdomainrequest
appendto
lpeg
asp.net-mvc-areas
coda-slider
suppress
gin
routedevent
user-friendly
compiler-specific
premature-optimization
text-coloring
post-build
multiple-languages
windows-live-messenger

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