I am creating a action using appendfile with actions to collect different content. I would like to use the action parameter query so a operator is required to insert a change management ticket number which is written into the file using a defined parameter for the value of the change management number so that this is dynamically created so another process can read this line where the parameter: “change management ticket” = number. . so far I have written
action parameter query “Change Management Ticket” with description “Please enter the Change Management Ticket Number you would like to add::” With Default “”
so the file would show something like this
parameter: “change management ticket” = number.
which would then add
appendfile CM:: {change management ticket number }
Jason thanks as made change to Change Management Ticket to CM and tested. worked great. Is there a way to force formatting such as length and or number of characters for the ticket number and blocks you from running action if you put nothing?
If you know how to find the start and end position of the ticket number or some other token in your file you could use createfile and then use preceding text of first <substring> and following text of first <substring> and concatenate in your new ticket number.
Q: preceding text of first "." of " log . text" & "123" & following text of first "." of "log . text"
A: log 123 text
Thanks for the response so that I understand I have added the file name and the location of the number I want to change. Can you modify you relevance to reflect below?
File name is “deltafile.yesterday.txt”
lines in the file. The CM:5555 is the change management record number i want to change. So CM: 5555 where i would want the new number to go. CM is the key field
CM: 5555
TimeStamp: 20160202 14:49:04
UID: ITEMSERVER
OS: Windows
Baseline: NEW
Title: CIP-010-R1-1 Windows Baseline.ITEMSERVER.02022016
Standard: CIP-010
Requirement: R1.1
Test Group:AD
Destination: EMS
CIP-010-R1-1.1.1 Operating System: Win2008 - 6.0.6002
What I would like to do is take a action with the action parameter query below
action parameter query “Change Management Ticket” with description
"Please enter the Change Management Ticket Number you would like to
add::" With Default “”
and replace the existing CM: 5555 with the new number similar to below’s example when it was a new file
appendfile {parameter “change management ticket” of action}
createfile until EOF
CM:{parameter “CMnumber” of action}
{concatenation “%0d%0a” of line whose (it does nit start with “CM” of file “c:\cm_file_path.txt”)}
EOF
I tried the above and got error message in log file
Command succeeded action parameter query “CM” with description “Please enter the Change Management Record Ticket Number you would like to add:” With default “” (action:3882)
" Command failed (Substitution failed while writing file) createfile until EOF (action:3882)"
Action file lines:
action parameter query “CM” with description “Please enter the Change Management Record Ticket Number you would like to add:” With default “”
createfile until EOF
CM:{parameter “CMnumber” of action}
{concatenation “%0d%0a” of line whose (it does not start with “CM” of file “c:\deltafile.yesterday.txt”)}
EOF
One last item. createfile is 0kb and is blank. I changed CM: 1234 without parameter statement and that will write to createfile but still same error message.
I made a bit of headway as I realized that the parameter needed to changed from CMnumber to CM is my action. That does write to the createfile. So the error is writing to the existing file.
Does that remove the other content of the file as I am just modifying the first line to the existing file with the new number? Do you mean
delete "c:\deltafile.yesterday.txt"
createfile until EOF
CM:{parameter “CM” of action}
{concatenation “%0d%0a” of line whose (it does not start with “CM” of file “c:\deltafile.yesterday.txt”)}
EOF
You have to build the complete new file first, before removing the old one. So something like
// start a new __createfile
// Begin the new __createfile with the new CM parameter
// Conclude the new __createfile with every line from the original file that does *not* start with CM:
createfile until EOF
CM:{parameter "CM" of action}
{concatenation "%0d%0a" of line whose (it does not start with "CM:" of file "c:\deltafile.yesterday.txt")}
EOF
// Now delete the original file
delete "c:\deltafile.yesterday.txt"
// Replace the original file with the new file
move __createfile "c:\deltafile.yesterday.txt"
I understand , however I am still failing with same error " Command failed (Substitution failed while writing file) createfile until EOF (action:3893)" on line
Failed
{concatenation “%0d%0a” of line whose (it does not start with “CM:” of
file “c:\deltafile.yesterday.txt”)}
// start a new __createfile
// Begin the new __createfile with the new CM parameter
// Conclude the new __createfile with every line from the original file that does *not* start with CM:
createfile until EOF
CM:{parameter "CM" of action}
{concatenation "%0d%0a" of lines whose (it does not start with "CM:" of file "c:\deltafile.yesterday.txt")}
EOF
// Now delete the original file
delete "c:\deltafile.yesterday.txt"
// Replace the original file with the new file
move __createfile "c:\deltafile.yesterday.txt"
Try it in the Fixlet Debugger, that may point to the particular line that’s giving an error.
Here is the response I get while running in action fixlet debugger with the error message in Quotes below in line 4. which highligts createfile until EOF. However I know it creates the file and it inputs the CM number so I think the failure is reading in the existing file into the createfile .
// start a new __createfile
// Begin the new __createfile with the new CM parameter
// Conclude the new __createfile with every line from the original file that does not start with CM:
createfile until EOF == // start a new __createfile
// Begin the new __createfile with the new CM parameter
// Conclude the new __createfile with every line from the original file that does not start with CM:
createfile until EOF “Error Message runtime error substitution failed while writing file Line 4”
CM:{parameter “CM” of action}
{concatenation “%0d%0a” of lines whose (it does not start with “CM:” of file “c:\deltafile.yesterday.txt”)}
EOF
// Now delete the original file
delete “c:\deltafile.yesterday.txt”
// Replace the original file with the new file
move __createfile “c:\deltafile.yesterday.txt”
CM:{parameter “CM” of action}
{concatenation “%0d%0a” of lines whose (it does not start with “CM:” of file “c:\deltafile.yesterday.txt”)}
EOF
// Now delete the original file
delete “c:\deltafile.yesterday.txt”
// Replace the original file with the new file
move __createfile “c:\deltafile.yesterday.txt”
I think I closed the parentheses in the wrong place on the “whose” clause:
// start a new __createfile
// Begin the new __createfile with the new CM parameter
// Conclude the new __createfile with every line from the original file that does not start with CM:
createfile until EOF
CM:{parameter "CM" of action}
{concatenation "%0d%0a" of lines whose (it does not start with "CM:") of file "c:\deltafile.yesterday.txt"}
EOF
// Now delete the original file
delete "c:\deltafile.yesterday.txt"
// Replace the original file with the new file
move __createfile "c:\deltafile.yesterday.txt"