zachzippo has asked for the wisdom of the Perl Monks concerning the following question:

I've written a PERL script that prompts the user for some information and then does it's thing. If I'm on the remote system via MS remote desktop, the script works fine. If I access the remote system using 'psexec' from System Internals, it doesn't. It's results are somewhat predictable. If I invoke the 'psexec' without the -i parm (the interactive flag), the system doesn't ask for any input. If I use the -i parm, it waits for the input and then displays the prompt. I've boiled my test program to a very short example below:
#! perl use strict; use warnings; my $commit; print "***********************\n"; $commit = <>; print "***********************\n";
In running the above example without the -i I get two rows of stars, with the -i it waits for a response and then gives two rows of stars. It's almost like I need a way to tell PERL to flush the STDOUT buffers before quering on STDIN, I think this is possible but don't know how.

I invoke the connection as "psexec \\{host} cmd" to get a command shell to run the programs. I'm running AS 5.8.3-811 under 2003 server std ed. I appreciate your meditations...

Replies are listed 'Best First'.
Re: psexec and PERL
by crashtest (Curate) on Feb 16, 2005 at 06:26 UTC
    I am not familiar with how you're remotely accessing your system, but if it's autoflushing your searching for, look no further than the documentation for $| in perlvar:
    use IO::Handle; STDOUT->autoflush(1);
    (This is documented in perlvar because you can achieve the same effect by setting $|).

    In fact, the blurb seems to apply directly to you, albeit in a more UNIXy context:

    If you have the Perl Cookbook ("Ram"), you can check Recipe 7.12. for an example. Hope this helps.
      Thanks, for the Autoflush infomration, I tried that this morning and it had no impact on the program. Continued to misbehave. I was able to run a few more test and determine it was in the "psexec" program that I was using for the remote connection. It was coming into the system in a way not compatable with AS Perl. If you know the oddities of windows and the almost STDIN and STDOUT it offers, then you have a good idea why it didn't work. Anyway, moved on to plan B. I'm running the interactive scripts on a citrix server. :) a little over kill, but why not.