Solution required. I am not able to read values on th screen
Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Solution required. I am not able to read values on th screen
PostPosted: Thu Aug 16, 2012 6:50 am 
Offline
Newbie

Joined: Thu Aug 16, 2012 6:36 am
Posts: 2
Hi Guys,

I have a requirement that I login to a Linux box, run an application on the box (this is a C++ application), go to a screen and read the values from the screen line by line and depending on business rule, I should be able to write the values from the screen on to a file.

I am able to do everything else what I want EXCEPT that I cannot read from the screen line by line. I tried filereadln command but that does not help.

I want to loop through the records one by one (I am able to loop) and read the values into variable ( I am not able to do this) and based on some condition, I want to either write the values in a file or move on to the next record.

I am farely new to teraterm macro and help from the experienced guys will really be appreciated.


Top
 Profile E-mail  
 
 Post subject: Re: Solution required. I am not able to read values on th screen
PostPosted: Fri Aug 17, 2012 5:10 am 
Offline
Newbie

Joined: Thu Aug 16, 2012 6:36 am
Posts: 2
Hi,

I am having a problem with TeraTerm macro. To begin with, let me explain you the whole situation.
I have an application running on a linux box. That application is obviously a Character Based Interface (C++ application). It has various screens which display tabular and form like data.
By macro, I am able to login, run the application, go to various screens on the applications, loop through the records on screens, screen scrape etc.
I am stuck at a place where my requirement is that
1. I go to a screen (I am able to do so).
2. Query All the records (I am able to do so).
3. Loop through the records (I am able to do so).
4. While looping, read the record and based on some condition, store them in a file.

I am not able to do the last part (4). I am not able to read the record while my cursor look like it is at that record. I have tried using setsync, recvln etc but nothing works.
One interesting point is that this application has a "status line" and when I do a recvln and display what is received from the remote host, I do not see the record where my cursor is but the value in the status line.

If you can help me in reading the records, it will really be great and I can then automate lots of things and do some performance testing

Thanks in advance.

Rukmesh


Top
 Profile E-mail  
 
 Post subject: Re: Solution required. I am not able to read values on th screen
PostPosted: Mon Aug 20, 2012 9:44 am 
Offline
Guru

Joined: Wed Jan 25, 2006 10:28 pm
Posts: 627
Location: Denver, Colorado, USA
It would help if you would post your current script and highlight where in that script you are having trouble.


Top
 Profile  
 
 Post subject: Re: Solution required. I am not able to read values on th screen
PostPosted: Mon Aug 20, 2012 2:07 pm 
Offline
Coach

Joined: Thu Jul 09, 2009 2:14 pm
Posts: 132
Hi,

Here is some code I used to dump the screen text to a file and then later post process this information. I have found more flexibility in post processing screen dumps of text versus attempting to perform conditional statement right from memory.

Hope this makes sense to you and you can tweak to your needs. :smile:

  1.  
  2.  
  3.     timeout = 60
  4.    
  5.     call Start_log
  6.     call Dump_screen_text_to_file_by_Querying_All_the_records
  7.     call Post_process_log_file
  8.    
  9.     end
  10. ;=================================================================
  11. :Start_log
  12. ;-----------
  13.     logclose
  14.    
  15.     pause 1
  16.    
  17.     ;Where to place the log files
  18.     ;---------------------------------------------
  19.     changedir 'c:'
  20.     pause 1
  21.     logopen 'c:\log.txt' 0 0 0 0 1
  22.     if (result > 0) messagebox 'log.txt did not open' 'USER MESSAGE A'
  23.     logstart   
  24.     flushrecv
  25.    
  26.     pause 1
  27.     setsync 1
  28.                
  29. return
  30. ;=================================================================
  31. Dump_screen_text_to_file_by_Querying_All_the_records
  32. ;-----------
  33.  
  34. ;PLACE YOUR CODE STARTING HERE
  35. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  36.  
  37.  
  38. ;~~~~~~~~~~~~~~~~~~
  39. ;Go ahead and place your code that dumps your records here and all this data
  40. ;will be placed on the "log.txt" file.
  41. ;~~~~~~~~~~~~~~~~~~
  42.  
  43. ;1. I go to a screen (I am able to do so).
  44. ;2. Query All the records (I am able to do so).
  45.  
  46.  
  47.  
  48. ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49. ;END HERE
  50.  
  51.  
  52.     logclose
  53.     fhandle = 0
  54.     fileclose fhandle
  55.     setsync 0
  56.    
  57. return
  58. ;=================================================================
  59. :Post_process_log_file
  60. ;-----------
  61.  
  62.     setdir 'c:'
  63.     fileopen fhandle 'c:\log.txt' 0
  64.     if (fhandle = -1) messagebox 'File will not open' 'USER MESSAGE B'
  65.  
  66.     ;----------------------
  67.     ;Forward searchs a string from a file.
  68.     ;----------------------
  69.     filestrseek fhandle 'FIRST START STRING HERE'
  70.     if (result=0) then
  71.        messagebox 'String Not Found' 'USER MESSAGE C'
  72.     endif
  73.  
  74.     filemarkptr fhandle
  75.  
  76.     filestrseek fhandle 'SECOND STRING HERE'
  77.     filereadln fhandle log_string
  78.         strscan log_string 'SECOND STRING PASSED'
  79.         result_tmp = result
  80.         if (result_tmp = 0) then ; STRING NOT SEEN
  81.            messagebox 'DID NOT FIND SECOND STRING' 'USER MESSAGE D'
  82.         endif
  83.         if (result_tmp > 0) then ; STRING DETECTED
  84.            messagebox 'FOUND SECOND STRING' 'USER MESSAGE E'
  85.         endif
  86.              
  87.     filestrseek fhandle 'THIRD STRING HERE'
  88.     filereadln fhandle log_string
  89.         strscan log_string 'THIRD STRING PASSED'
  90.         result_tmp = result
  91.         if (result_tmp = 0) then ; STRING NOT SEEN
  92.            messagebox 'DID NOT FIND THIRD STRING' 'USER MESSAGE F'
  93.         endif
  94.         if (result_tmp > 0) then ; STRING DETECTED
  95.            messagebox 'FOUND THIRD STRING' 'USER MESSAGE G'
  96.         endif
  97.              
  98.     fileclose fhandle
  99.    
  100. return
  101.  


Top
 Profile E-mail  
 
 Post subject: Re: Solution required. I am not able to read values on th screen
PostPosted: Tue Aug 21, 2012 12:18 pm 
Offline
Newbie

Joined: Wed Jun 18, 2008 6:00 pm
Posts: 22
Here's an example of scraping specific parts of a window. This is the method I use.

viewtopic.php?f=13&t=898

_________________
"The conclusive proof that intelligent life exists elsewhere in the Universe lies in the fact that no one has bothered to contact us." --unknown


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group