I need to emulate the following with a script which is invoked by a web service run from a Linux server:
- Access remote AIX server via SSH
- Log into an Intersystems Cache instance (if that's unfamiliar, pretend we're loading an interactive Python or Ruby [irb] environment)
- Execute commands
- Execute more commands depending on output of previous commands
- Log all input to and output from this environment
This is fairly trivial to do in C# with the SSH.NET library. Open a shellstream to the remote host, attach a StreamReader and StreamWriter, then send input to the SSH connection via StreamWriter and read output from it via StreamReader.
How should I go about this on a Linux server with ssh? I am experimenting with screen, but it seems more designed more for human-interactive use than by scripts, and I wonder if I am barking up the wrong tree.
I don't have control over what's installed on the AIX server. I might be able to get things installed there but no guarantees.
Much later edit: possible solutions include pexpect/pxssh (Python), paramiko (also Python)