Using the pseudo terminal to automate a command execution can bring you nasty side effects. setPty method: Channel channel=session.openChannel("exec") Check Session > Close window on exit > Never and open the session.Īnother (not recommended) approach is to force the pseudo terminal allocation for the "exec" channel using the. Then go to Connection > SSH > Remote command and ether your ping source. For example in PuTTY, it's Connection > SSH > TTY > Don't allocate a pseudo terminal. To verify that this is the root cause, disable the pseudo terminal allocation in your SSH client. You should find out what is it that breaks the ping and fix your startup scripts accordingly. The ping is not an interactive command, so it should work even on the non-interactive session. If this breaks the ping command, it's clearly misconfiguration on the server-side, not JSch fault. So the environment might differ from the interactive session you use with your SSH client. And/or different branches in the scripts are taken, based on absence/presence of the TERM environment variable. As a consequence a different set of startup scripts is (might be) sourced. The "exec" channel in the JSch (rightfully) does not allocate a pseudo terminal (PTY) for the session. The ping command probably depends on some environment variable or other configuration to resolve the source address. But I will trust you that it works in the terminal. Your ping source x.x.x.x host y.y.y.y syntax seems strange to me. ping source x.x.x.x host y.y.y.y -c 5 -s 500 (not working)Ĭode: public static void main(String arg).What is the difference between two commands using JSch setCommand? ![]() I need to make the program to ping from different source interface IPs. ![]() ![]() If I manually execute both commands from the x-terminal, the both commands works fine. But if I add addition ping options, "ping source x.x.x.x host y.y.y.y -c 5 -s 500", I got If I set simple ping command, "ping y.y.y.y -c 5 -s 500 " into setCommand() function, it works as designed.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |