Dear Monks,

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:

ssh account@HostA my_command
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).

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

@result = `ssh account@HostA my_command`;
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."

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!


In reply to Perl, Unix terminals, and SSH complicated combination by RaduH

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.