Did you open an ssh connection to the remote machine, get a "shell" and then execute "./interactive_command.sh" within that shell?
If that's the case, then there's really no way for the "connection" itself to know if a command has finished because it's executing in the context of the shell.
This guy had a similar problem and appended ; echo "MAGICSTRING" to every command and then searched for "MAGICSTRING"
http://blog.james-carr.org/2006/07/11/ssh-over-java/
You might try using SSHCommand passing in all three lines as one command...
If that's the case, then there's really no way for the "connection" itself to know if a command has finished because it's executing in the context of the shell.
This guy had a similar problem and appended ; echo "MAGICSTRING" to every command and then searched for "MAGICSTRING"
http://blog.james-carr.org/2006/07/11/ssh-over-java/
You might try using SSHCommand passing in all three lines as one command...