Perl SSH without a perl module

I'm trying to create a perl script that will do 1 SSH session, but be able to write multiple commands to the session and receive multiple outputs. I know there are modules out there like Net:SSH::Perl, but I'm not allowed to use it. I was thinking of doing something like an open3 on an ssh session. After that, I would potentially be able to send commands and receive output from stdout and stderr (maybe). I'm thinking there's a flaw here in my logic, but I can't think of what it is. Before sitting down and writing myself into a corner, have any of you done something like this before? Can anyone point of the flaw in my logic? I'm not sure if it'll work, but I'd be very frustrated if I were to code something that could never have worked.

Thanks in advance for any and all input.

Do you have to use perl?

What OS(es) and shell?

Yep. We're using Solaris, which has become a pain in the butt. There are a few modules out there that come default with many Linux distros, but not for Solaris. We use ksh most times. I'm not really looking for some backtick solution that requires passing a long shell script. I'm determined to figure out a better way.

What, precisely, are you trying to do? Remember that you can send entire shell scripts over ssh. Maybe there's a non-perl solution.

cpan has thousands of modules.

You do not have to put them in a system directory, just deploy them in a user/application directory and add them to @INC. So, in that sense you can use whatever you want/need.

And generally, creating ssh sessions in shell is trivial. Otherwise in perl you call fork/exec to another module or perl subroutine to do your work. This is how you get around backticks. fork/exec creates a child process which you can manipluate by "owning" tty stdin/stdout in the parent perl module. If you want.

I think you might want to look at Stevens 'Advanced Programming in the UNIX Environment'. It is C, but Solaris perl has a complete interface to the calls mentioned there. Or. Google for 'Perl UNIX system programming'. Lots of system-level perl code for UNIX/Linux is avalable is out there.

Short answer: yes you can do what you want, pretty close to your description. You need to pick up more about UNIX system programming first.