How to Insert a line into a text file

Article:HOWTO8717  |  Created: 2005-09-12  |  Updated: 2007-09-26  |  Article URL http://www.symantec.com/docs/HOWTO8717
Article Type
How To



Question

How do I insert a line into a text file?

Answer

In Wisescript Editor/Wise Installation Systems, add an "Insert Line into Text file" action. Fill in the following information:

File to Edit: Enter a pathname to the text file you want to edit or use variable substitution to build a pathname. EX: %MAINDIR%\TEST.TXT

Text to Insert: Enter the command line you want to add to the file. If the line refers to a directory or file, use a full pathname built with variable substitution (such as %MAINDIR% to specify the application's directory) so the path is correct regardless of the directory where the user installs your software.

Line Number: The line number at which the new line should be inserted. Specify zero to append the command to the end of the file. The Search for Existing Text panel in this dialog box overrides any line number specified here; the line number applies only when the text is not found or when you do not specify any text.

Search for Text: Enter the text for which you want to search. The installer scans the file looking for a line that begins with, ends with, or contains the text (depending on the setting of the Match Criteria field). If more than one line in the file matches, only the first is edited.

Comment Text:  Enter the text to insert at the beginning of the line when it has been found. This can be useful when you are replacing an existing command with a new command and want to leave the existing command in place but inactive. In this case, you should always set the Insert Action drop-down to cause your new command to be inserted before the existing line so that a subsequent installation finds and edits the active command, not the commented-out line.

Insert Action: Select the action to be taken when a line containing the specified text is found. You can either insert your new command before the existing line, replace the existing line with your new command, or insert your new line after the existing one.

Match Criteria: Choose whether the line must begin with, contain, or end with the text entered in the Search for Text field.

Ignore white space: If this checkbox is marked, the search operation ignores spaces and ab characters.

Case-sensitive: If this checkbox is marked, the search operation distinguishes between uppercase and lowercase text.

Make Backup File: If this checkbox is marked, the installation makes a copy of the file before editing it. The backup has the same file name except with a number appended to the end. The backup is retained after installation so that the user can undo any changes made to it if they cause problems.

Samples of this action is available in the Samples folder called Textfile.wse.  The Samples folder can be found in the following locations based on your product:

Wise Package Studio:  C:\Program Files\Altiris\Wise Package Studio\WiseScript Editor\Samples
Wise Installation Systems: C:\Program Files\Wise Installation System\Samples
Wise Installation Studio: C:\Program Files\Altiris\Wise Installation Studio\WiseScript Package Editor\Samples


 


Legacy ID



4094


Article URL http://www.symantec.com/docs/HOWTO8717


Terms of use for this information are found in Legal Notices