I'm confused as to what you're trying to accomplish here. You want the output of this command (which means waiting until the output is closed) or to run in the background? You can't do both - at least not with qx. If you want the application to run in the background while you continue, you will, by definition, not get any lines back immediately. You can do this with proper threading or event handling, but you're still not going to get lines immediately. I'm not even sure that you really want the lines, but you're specifically asking for it, so I'm assuming there's a reason why you're using qx instead of system.

Further, I'm confused by those quotes inside the qx. That doesn't make any sense to me whatsoever. If the open double-quote was after the -i, that'd make more sense.

Another option, if you don't need the output, is to use system(1, $cmd) - on Windows, that should start the command in the background, though it'll leave the connection open.

I'd suggest using nohup and redirecting output (the latter which salva suggested). And maybe look into whether plink has some of the ssh options that force its connection into the background.


In reply to Re: Control not coming back to perl script by Tanktalus
in thread Control not coming back to perl script by parthodas

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.