Link to home
Start Free TrialLog in
Avatar of silentreproach
silentreproachFlag for United States of America

asked on

Debug plain text input

My script's purpose is to perform .NET functions on a PC client, and it talks back and forth using plain text:
 
a) The script prints plain text, which is intercepted by the client and tells the client which .NET operations to perform (this part is working great).

b) The Windows client (basically a glorified telnet client) sends responses in plain text back to the perl script (with perhaps a CR/LF after each line of text - maybe this is the problem)

The only line that is giving me trouble is the one exiting the loop:

       last if $text eq '3Click,MyForm.button1';

The script exits correctly if i manually run it from the # prompt and type:

       3Click,MyForm.button1

followed by pressing the ENTER key.

The problem is the script does not end when my client sends this text.  Are there alternatives to chomp that I should be using?  To debug, is there a way I can dump the value of $text into a file during each pass through the loop, so I can see what text the script is receiving?  Or is my syntax just inappropriate for the application?

The script:

   #!/usr/bin/perl                                          
                                                         
   # Enter TrueGUI mode:                                    
   print "\$\$EnterTrueGuiMode\$\$\n";                      
                                                         
   # Load the set of Windows Forms we created with Visual Studio:        
   print "{ TrueGui.LoadAssembly(`WindowsApplication1`) }\n";
                                                         
   # Create an instance of Form1 calling it "MyForm"        
   print "{ MyForm = New WindowsApplication1.Form1() }\n";  
                                                         
   # Show MyForm                                            
   print "{ MyForm.Show() }\n";                              
                                                         
   while(1) {                                                
      $text=<STDIN>;                                        
      chomp($text);                                          
      last if $text eq '3Click,MyForm.button1';              
   }                                                        
                                                         
   # end of script                                          

Thanks,
Andrew
ASKER CERTIFIED SOLUTION
Avatar of Adam314
Adam314

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial