• Support
  • Articles
  • Resources
  • Products

Solution required. I am not able to read values on th screen

Moderator: boris

5 postsPage 1 of 1

rukmesh
Newbie

Posts:
2
Joined: Thu Aug 16, 2012 10:36 am
by rukmesh » Thu Aug 16, 2012 10:50 am
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.
rukmesh
Newbie

Posts:
2
Joined: Thu Aug 16, 2012 10:36 am
by rukmesh » Fri Aug 17, 2012 9:10 am
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
IshmaelCallMe
Guru

Posts:
650
Joined: Thu Jan 26, 2006 2:28 am
by IshmaelCallMe » Mon Aug 20, 2012 1:44 pm
It would help if you would post your current script and highlight where in that script you are having trouble.
dpena
Coach

Posts:
139
Joined: Thu Jul 09, 2009 6:14 pm
by dpena » Mon Aug 20, 2012 6:07 pm
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:

Code: Select all

  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.  
cwaters
Newbie

Posts:
22
Joined: Wed Jun 18, 2008 10:00 pm
by cwaters » Tue Aug 21, 2012 4:18 pm
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
Display posts from previous:
Sort by:

5 postsPage 1 of 1

Users browsing this forum: No registered users
cron