Sign in to follow this  
Followers 0
Lmac34

Help with StdinWrite and StdoutRead

3 posts in this topic

Hi Everybody!!!!

im in need of some help?

i have a small perl script that displays some text and requires input from a user.

eg

#!/usr/bin/perl -w
use strict;

my $test1 = "";
my $test2 = "";

print "Enter the 1st option:\n";
$test1 = <STDIN>;

print "Enter the 2nd option:\n";
$test2 = <STDIN>;

print "\nYou Entered: ";
print $test1;
print "\nYou Entered: ";
print $test2;

im trying to put a gui using autoit onto this perl script and display the output from the perl script into an edit box.

im havig to problems when i use

$cmd = "perl -w " & '"'&@ScriptDir&"\test2.pl"&'"'
$foo = Run($cmd, @ScriptDir,@SW_HIDE,$STDOUT_CHILD + $STDIN_CHILD)

it freezes,

when i use

$cmd = "perl -w " & '"'&@ScriptDir&"\test2.pl"&'"'
$foo = Run($cmd, @ScriptDir,@SW_SHOW,$STDOUT_CHILD + $STDIN_CHILD)

and close the command box it gets the fist line and then freeses

i have tryed writing

StdinWrite($foo,$cmdin1 & @CRLF)
StdinWrite($foo)

but it still ends up in a infinte loop

$cmd = "perl -w " & '"'&@ScriptDir&"\test2.pl"&'"'
$foo = Run($cmd, @ScriptDir,@SW_HIDE,$STDOUT_CHILD + $STDIN_CHILD)
        
Dim $display = ""
;$list = ProcessList("perl.exe");
        
While 1
                $line = StdoutRead($foo); get line from Stdout
               ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                If @error = -1 Then ExitLoop
                $display &= $line; append line to display
                GUICtrlSetData($Edit1,$display);update screen display
               ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
               ;StdinWrite($list[1][1],$cmdin1 & @CRLF)
               ;StdinWrite($list[1][1])
                StdinWrite($foo,$cmdin1 & @CRLF)
                StdinWrite($foo)                        
Wend

Anyone got an ideas?

any help ill be must Appreciated

Thanks

Share this post


Link to post
Share on other sites



Calling StdoutRead with only one argument tells the function "read the first batch of characters that become available, and wait as long as you need to to do so." There hasn't been any input to your perl script at the time that you call StdoutRead so there won't be any output yet, thus the freeze.

Also, StdoutRead is going to "eat" the output from perl that would be going to the console, so you won't see any of the perl prompts in the console, but they would show up in the edit box.

Lastly, I don't think your script is assembled the way you intend it to be. Putting a while loop around StdoutRead and testing for @error = -1 is done when you believe the child program will write its output and exit and you wish to get all the output, StdoutRead only returns @error = -1 when the child's output pipe has broken, which usually happens at exit of the child process. For the purpose of your test script a function outside the GUI message loop with pairs of StdinWrite and StdoutRead (with no looping) would have the desired result.


Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post


Link to post
Share on other sites

so are there any updates? I would love to see the whole script even if it doesn't work.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0