java - Calling a shell script using SSH exec channel, but it ignores calls to other shell scripts -


i managing execute shell script on remote server using jsch exec using helpful examples provided here. can see echoes being returned script , exit status @ end 0 - looks @ first glance.

however, problem script calls out other scripts, , these appear ignored, skipped over.

the script calls other scripts directly. i.e. first line of script like:

script_two.sh 

could advise of way overcome this? did start "shell" channel instead of "exec", may tricky in case because before giving user access system, server presents form fill in (name, number, why logging in, etc) - haven't yet been able to programmatically fill in , submit form, stick exec if possible.

i new this, help/advice welcome!

code snippet below. said, appears work, sh script represented "scriptfilename" int code calls other sh scripts, , these not executed.

many in advance help, j

jsch jsch = new jsch(); jsch.setconfig(filetransferconstants.strict_host_key_checking, "no");  session session = jsch.getsession(username, hostipaddress, port); session.setpassword(password); session.connect();  //create execution channel on session channelexec channelexec = (channelexec)session.openchannel("exec");  channelexec.setcommand(scriptfilename); channelexec.connect(); 

i assume script looks like:

script_one.sh script_two.sh 

i.e. script relies on . (the current path) being in path environment variable, not default.

so script ever work, . has added path in startup script. it's quite probable addition occurs (probably unintentionally incorrectly) interactive sessions. because addition done in startup script executed (sourced) the interactive sessions only.

the "exec" channel in jsch (rightfully) not allocate pseudo terminal (pty) session. consequence different set of startup scripts (might be) sourced than, when login ssh client. and/or different branches in scripts taken, based on absence/presence of term environment variable. environment might differ interactive session use ssh client.


solutions (in preferred order):


see related question shell ping command source option failing when executed using jsch setcommand.


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -