jcabi / jcabi-ssh

Java SSH client (an object-oriented wrapper around JSch)
https://ssh.jcabi.com
Other
252 stars 88 forks source link

How to send data & read the response continuously #42

Open herusdianto opened 8 years ago

herusdianto commented 8 years ago

Thankyou for this great library Sir.

I have some questions, here is my flow:

  1. I connect to server A via SSH.
  2. After connected, then I want to connect to server B using netcat with this command: netcat -q -1 host port.
  3. Then I send data to server B for log on (ISO 8583).
  4. I send data to server B for echo test (ISO 8583).
  5. I send data to server B continuously for financial transaction (ISO 8583).
  6. I want to read the response from server B everytime I send the ISO.

But it always throw an error like this: java.lang.IllegalArgumentException: non-zero exit code #127: ISO0110000170800100000100010000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000204153211031510001 <= log on message

My terminal output:

heru@aaa:~$ netcat -q -1 host port
ISO0110000170800100000100010000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000204143453093937001 <<< request logon
ISO011000017081010000010001000000000000000000000000000100000000000000000000000000000010000000000000000000000000000000000000000000000000000000000020414345309393700001 <<< response logon

ISO0110000170800100000100010000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000204143559059307301 <<< request echo
ISO011000017081010000010001000000000000000000000000000100000000000000000000000000000010000000000000000000000000000000000000000000000000000000000020414355905930700301 <<< response echo

ISO011000017020001110010001110100100000000000001000010001000001110000000000000101600000000000000003000000000000000000204141138098412141138020402047010040916000000000000000000000000000000400000250239865570310000411612100360006000001      <<< request financial
ISO011000017020001110010001110100100000000000001000010001000001110000000000000101600000000000000003000000000000000000204141138098412141138020402047010040916000000000000000000000000000000400000250239865570310000411612100360006000001aaaaa <<< response financial

My question is, how to send and read the response from server B continuously using this library? Thankyou & sorry for my bad English.

dmarkov commented 8 years ago

@yegor256 dispatch this issue please, see par.21

yegor256 commented 8 years ago

@herusdianto I think you just need to not close the InputStream and keep pushing data there. Also, don't close the OutputStream and keep reading from there. That should work, provided your server command don't quit and keeps running.