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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy data to text file and add character

Status
Not open for further replies.

Majaws2

Programmer
Jul 3, 2003
15
US
I have a script that runs on 100+ servers. It captures the following data (size will vary) I would like to save this as a text file, but add an x before the numbers in the triplet column. There is other data in my capture file that I don't want to see. Just from the first entry after CALLS to ENTER (data between those words) and add an x (make the 1:9:0 into x1:9:0, etc.)any ideas..

TRIPLET SEC_BUSY CALLS
1:9:0 3891 85
1:9:1 3586 93
1:9:2 3584 89
1:9:3 3129 95
1:9:4 3819 89
1:9:5 3406 92
1:9:6 3832 85
1:9:7 3947 85
2:7:7 3189 87
3:7:0 3636 89
3:7:1 3044 93
3:7:2 3404 90
3:7:3 3925 83
3:7:4 4039 83
3:7:5 3363 89
3:7:6 3497 89
3:7:7 3511 93
ENTER (A,B,C,D,E,F,G,H,R,X):
 
Will the format of the triplets column always be:

number:number:number

where the number is always a single digit? Is the position of the data always the same on the line (i.e. first number always appears in the same column)? If so, you could open the capture file after it has been saved, read line by line until you get to the first line to modify. You could then use the strputc command to modify the value just before the triplet column. Here is some code to find the first colon in the string read from the capture file, then place the x in the desired location (assuming my previous assumptions are correct):

proc main
string sLine = " 1:9:0 3891 85"
integer iPos

if strfind sLine ":" iPos
strputc sLine iPos-2 120
usermsg "%s" sLine
endif
endproc

Once you have modified the line, you'll need to write it back to the file. I have a sample script at that shows how to do the various manipulations with the file pointer to get the new data in and the file saved.


aspect@aspectscripting.com
 
I will play with this to see what I can do.. (NOVICE though), the first digit is always single digit, second single or double, third single or double. So could see like a 1:9:0 or a 1:9:24 or 1:15:0

Thanks for the above.. I will see if I can modify
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top