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!

Creating a table with string variables

Status
Not open for further replies.

milo63

Technical User
Jul 3, 2002
17
US
I need to write a script to gather the checksum values for a few different files and display them in a table format. I would like the table to be in this format:
File Name Expected Actual
atlas2pega 986C4452 986C4452
dicom2pega 1FCCC2221 5ER33345 etc...

Should I use a single capture file or multiple capture files? I will probably looking at about 10 files or so.

After logging in to the Unix machine I would do the following steps:
cd to desired directory
ascsum filename
capture the output
assign captured output to a string
print table with all the expected and captured strings

Any help is appreciated.
 
If you are just connecting to one machine, then the easiest way is to probably capture all the output into one capture file, then parse that for the information you are interested in. The easiest would be to search line by line for the prompt, knowing that the next line would be the results of the command. Once you have that line, you can parse it for the different values, then build your table line by line. Depending on if you know how many files you are summing, you could have a string variable for each line of results in the table, or write each line to a text file then print that result.
aspect@aspectscripting.com
 
Hello,

Can you Post the OutPut from the Unix Box after you issue the "ascsum filename" Command ? Ifso, I'll see what I can come up with.

Hank
camphm@bellsouth.net
 
Here is the output of the capture file with 3 checksums. . The first line of each SUPERUSER prompt is the command and the rest is the output. Thanks in advance.

SUPERUSER@adac:#[3] ascsum $PEGXBIN/atlas2pega

* FILENAME CHECKSUM(CRC)
*
/usr/adac/pegx/bin/solaris/atlas2pega C7B52473

FILE_TOTAL C7B52473
SUPERUSER@adac:#[4] ascsum $PEGXBIN/add_to_db

* FILENAME CHECKSUM(CRC)
*
/usr/adac/pegx/bin/solaris/add_to_db 1F656216

FILE_TOTAL 1F656216
SUPERUSER@adac:#[5] ascsum $PEGXSCRIPTS/generic_add_db

* FILENAME CHECKSUM(CRC)
*
/usr/adac/pegx/scripts/generic_add_db D6203F0B

FILE_TOTAL D6203F0B
SUPERUSER@adac:#[6]


 
Milo,

From the Example you Posted, Please Post how you would want it to Appear. Do you want this sent to a File or Just your Terminal ?

Thanks

Hank camphm@bellsouth.net
 
Hank, I would like the table to appear on my terminal. It should look something like this:

Filename | Expected | Actual
------------------------------------
atlas2pega C7B52473 C7B52473
add_to_db 1F656216 1F656216
generic_add_db D6203F0B D6203F0B
 
Milo,

I should have somethingfor you this evening.

Hank camphm@bellsouth.net
 
Milo,

In your Example, Is the FILE_TOTAL the Actual or the Expected ??? I have the Script ready But want to make sure this Item is Correct Before Posting it.

Thanks

Hank camphm@bellsouth.net
 
The FILE_TOTAL is the actual checksum.
 
Milo,

Here's what I came up with. I added a Column that indicates if there is a Mismatch between the Actual and the Expected. Note that the sDash should be on a Single Line.

Letme know if this works for you.

Hank


Proc Main
String sHeader = " File Name: | Expected: | Actual: | Mismatch:"
String sDash = "---------------------------------------------------"
String sBlank = " "
String sLine, sUsr, sExp, sAct, sOut
String sTok1, sMis

If not isfile "C:\Files\Milo_Cap.txt"
Usermsg "Capture File Not Found"
Exit
Endif

Clear
Termwrites sBlank
Termwrites "`r`n"
Termwrites sHeader
Termwrites "`r`n"
Termwrites sDash
Termwrites "`r`n"
Fopen 1 "C:\Files\Milo_Cap.txt" Read Text
While Not Feof 1
Fgets 1 sLine
If Strfind sLine "/usr"
Strtok sTok1 sLine " " 1 ; /Path
Strtok sExp sLine " " 1 ; /Expected
strrev sTok1
strtok sUsr sTok1 "/" 1 ; User
strrev sUsr
Endif
If Strfind sLine "FILE_TOTAL"
Strtok sTok1 sLine " " 1 ; File_Total
Strtok sAct sLine " " 1 ; Actual
If strcmp sAct sExp
sMis = " "
Else
sMis = &quot;<--- Y&quot;
Endif
Strfmt sOut &quot;%15s %s %s %s&quot; sUsr sExp sAct sMis
Termwrites sOut
Termwrites &quot;`r`n&quot;
Endif
Endwhile
Fclose 1
Endproc camphm@bellsouth.net
 
Hank, this is a good start. I don't see where you are getting the expected values. Both of the values in the capture file are the actual values (i.e - the full path checksum and the FILE_TOTAL checksum are both actual checksums). I think there would need to be some kind of lookup table to compare the expected values to the actual values. Also, would it be possible to display the results with usermsg window rather than on the terminal? How much trouble would it be to change the color of the font for any checksum where the actual did not match the expected? That way we wouldn't need the mismatch column. Thanks for your efforts. I really appreciate it.
 
Milo,

How would you Calculate the Expected Value to the Actual Value. We can create a Lookup Table but I'd need to know if it already exists or Not. The Lookup Table wouldhaveto reside in the PC with Procomm.

Hank camphm@bellsouth.net
 
How about just defining the expected values as string variables and then comparing them to the actual checksums. I know what the expected values are. Would that be better? Also what would happen if the file did not exist?
 
Milo,

You would use the Strcmp as illustrated above. If the Lookup Table File did not exist, the script would FAIL.

String sChkSum = 123D45C8

If strcmp sAct sChkSum
sExp = &quot;GOOD&quot;
Else
sExp = &quot;BAD&quot;
Endif

hank camphm@bellsouth.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top