RaduH has asked for the wisdom of the Perl Monks concerning the following question:
My scenario involves 3 machines. I run my script on HostC. This script sends commands to HostA to be executed on HostA or sends commands to HostA ansking it to execute them on HostB (for example C asks A do do ls -la or C asks A to ask B to do ls -la). Not reaching HostB directly from C is a constraint I have to live with.
To do this, I send my commands like this:
Then HostA decides if it executes the command or forwards it to HostB (or well, the command for HostA is to fwd another command to HostB).ssh account@HostA my_command
I used to use the 'system' command and everything was just fine up to the moment when I got interested in the result of one of these commands (as in I wanted to get a string back, not only the exit code of the operation). Reading that 'system' returns the exit code received from the SSH command, suddenly I became interested in printing the result I was interested in, capturing the output and parsing it for my keywords.
Since I was interested in the output, I have moved from using the 'system' call to using back ticks ` ` and my call is now something like
And then I browse the lines in @result looking for my answer. This works OK for the HostC-HostA interaction but when HostA needs to forward the command to HostB and collect the response the same way I get the error "Pseudo-terminal will not be allocated because stdin is not a terminal."@result = `ssh account@HostA my_command`;
As a side note, when I was using the 'system' call I was able to follow on HostC the debug messages from both HostA and HostB when the command was forwarded. But in this case I cannot get my hands on the output.
Any idea how/if this can be fixed? Please feel free to ask me additional questions if I missed to specify something.
Many thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl, Unix terminals, and SSH complicated combination
by shmem (Chancellor) on Dec 13, 2007 at 23:37 UTC | |
by RaduH (Scribe) on Dec 14, 2007 at 00:39 UTC | |
|
Re: Perl, Unix terminals, and SSH complicated combination
by almut (Canon) on Dec 13, 2007 at 23:53 UTC |