Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

conditional automated connection

Status
Not open for further replies.

zeroendless

Programmer
Mar 20, 2003
23
US
Hi, guys.
Totally new to Aspect and been reading and searching this thread for answer, Here's is i want to do.

I need to connect to a host using the connection directory entries ( data class, entries name "Test") , log in, password then choose service, capture the screen, save into file. This has to be done daily, without human interaction.
i know how to schedule windows task with bat file.

Anyway, so far, I'm able to automate the login, capture the file, trim and extract unwanted prints from file, resave in another file.

Here's my problems,
1)how do i call the connection directory put into the script, so when i exe "pw5 sriptname" in cmd, it will dial, then exe the script?
2)say i already saved the file, how do i call the file again, check for string "99," ( error checking if file is completed)
while not "99," repeat the whole process again, if not success after 5 times, waiting for 10 minutes, try it again.

it's sounds like a better way to check if the file is completed? the "99," is the key to determind if prints on screen is completed. Or may be i can apply the error checking based on the prints on screen before saving the file? help me up, thx u

quick sample of the capture file, the only data is i need is row from 01 to 99

........................................
Connected to xxxxxxx
CUSTOMER ID: xxxxxxx
CUSTOMER PASSWORD:
OPERATOR ID: xxxxxxx
OPERATOR PASSWORD:

WELCOME TO xxxx USA


ON AT 19MAR03 10:06 EST CONNECTED TO TERMINAL \xxx.xxxx.xxxx

DESIRED SERVICE: abcd
READY INPUT DEVICE - ENTER A CARRIAGE RETURN TO BEGIN REPORT
01,xxx,xxx,xxx,eee,dd,80,1,2/
02,xxx,xxx,1,030318,xxx,xxx,1/
03,xxx,USD,15,2600,,Z,20,xxx,,Z,25,200,,Z,40,2600,,Z,45,2500,,Z,50/
88,800,,Z,55,200,,Z,72,100,,Z,74,0,,Z,75,0,,Z,100,100,1,Z,182,100,,Z,400/
88,0,0,Z,482,0,,Z/
16,175,100,,,6,/
49,10100,5/
98,10100,1,7/
99,10100,1,9/

DESIRED SERVICE:
-------------------------------------------



 
There are two ways you can handle the script and Connection Directory entry integration. You could associate the script with the Connection Directory entry (click on the Basic Options button and assign the script), or you could dial the entry from within your script by using dial DATA "Test". In the first case, your command line would include just the Connection Directory entry, while the second choice would have the script file in the command line.

I'm not quite certain what you need with the 99, but there are a couple different ways to look for it. You could use the when target command to trigger when that string is received by Procomm. The when command would call a procedure you have defined in your script that would handle the situation in the appropriate manner. However, the when target command cannot determine if the 99, is at the beginning of a line or somewhere else in the report. The best thing to do may be to capture the file to disk, then search it for the string you are looking for. Here is some sample code to do that:

proc main
string sLine
integer iCount = 0

fopen 0 "filename" READ TEXT
while not feof 0
fgets 0 sLine
if strcmp sLine "99,"
;99, was found
iCount++
endif
endwhile
fclose 0
if iCount == 0 ;No 99, found in file
;Perform necessary steps...
endif
endproc

You would need to replace filename in the fopen command with your capture file. This script works by opening the capture file, checking the first three characters of each line for 99, and incrementing the value of iCount by one each time 99, is found. If it is not found at all, iCount will be zero and your script can key off that fact to take the necessary steps. aspect@aspectscripting.com
 
Hello,

You can do an AutoDial using the DialLoad Command if you have a Connection File that Contains the Number and Terminal Settings Defined.

Example:

string sDir = "C:\Procomm\EDS.dir"

Dialload sDir ;* Load EDS Connection Directory Entry

Hank
 
Thank Guys,

I used the sendkey and sendvkey to automate the the connection directory and it works fine.

Back to the error checking,
i have the file trimed to eliminate screen capture down to
------------
01,xxx,xxx,xxx,eee,dd,80,1,2/
02,xxx,xxx,1,030318,xxx,xxx,1/
03,xxx,USD,15,2600,,Z,20,xxx,,Z,25,200,,Z,40,2600,,Z,45,2500,,Z,50/
88,800,,Z,55,200,,Z,72,100,,Z,74,0,,Z,75,0,,Z,100,100,1,Z,182,100,,Z,400/
88,0,0,Z,482,0,,Z/
16,175,100,,,6,/
49,10100,5/
98,10100,1,7/
99,10100,1,9/
--------------
and increment "count" on each line, how do i check if the last line "99,10100,1,9/ the STRING "9" is equal to the INTEGER "count". The last value "9/" at last line is the total number line in the file record. I wonder how to used strtok to capture just the alphanumeric number 9 instead of 9/ and compare to the interger variable Count.
 
Hello,

You should use the ATOI Command. You'll set you Counter to a Number (Integer Count). Then Grab the 99 and change it to an Integer with ATOI. Then you can compare the two Values.

Hank
 
Hi, Hank.

Thank for the tip, I tried with ATOI and made the comparison. It worked and able to trap the errors and create error or success flag file. But, it gives error "Error 5 : invalid identifier" during the execution.

string Flagerror ="C:\Program Files\Symantec\Procomm Plus\Capture\Flagerr.txt"
string Flagsuccess ="C:\Program Files\Symantec\Procomm Plus\Capture\Flagsuc.txt"
string File1 ="C:\Program Files\Symantec\Procomm Plus\Capture\bacopy.txt"
string CopyFile2 ="C:\Program Files\Symantec\Procomm Plus\Capture\ba2cap.txt"
string LineToCopy
string LineCopy
string sTok1
string sTok2
integer iCount = 0
integer totalRecord
proc main

fopen 1 File1 read text
fopen 2 CopyFile2 create text
while not feof 1
fgets 1 LineToCopy
LineCopy = LineToCopy

strtok sTok1 LineToCopy "," 1
if strfind sTok1 "01"
fputs 2 LineCopy
iCount++
endif
if strfind sTok1 "02"
fputs 2 LineCopy
iCount++
endif
if strfind sTok1 "03"
fputs 2 LineCopy
iCount++
endif
if strfind sTok1 "88"
fputs 2 LineCopy
iCount++
endif
if strfind sTok1 "16"
fputs 2 LineCopy
iCount++
endif
if strfind sTok1 "49"
fputs 2 LineCopy
iCount++
endif
if strfind sTok1 "98"
fputs 2 LineCopy
iCount++
endif
if strfind sTok1 "99"
fputs 2 LineCopy
iCount++
strtok sTok2 LineToCopy "," 3
atoi sTok2 totalRecord
endif
endwhile
if totalRecord == iCount
fopen 3 Flagsuccess create text
fputs 3 sTok2
else
fopen 4 Flagerror create text
fputs 4 sTok2

endif

fclose 4
fclose 3
fclose 2
fclose 1
pwexit
endproc
 
Nevermind, Error solved. files need to be closed inside the if-else statement

Thank
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top