Absent Member.. bpscarbrough Absent Member..
Absent Member..
109 views

Creating an empty text file using FS Write Operation

I need a way to create an empty text file without any newlines or anything.  I'm trying to use the COUNT result to bring back the number of lines in the file as I write to it.  The initial creation of the file should be empty without any lines.  However, it looks like it returns a COUNT = 1.0.  I am writing this file to my Central Windows 2008 server.

 

Inputs are as follows:

file = \\${centralHost}\c$\Temp\somefilename.txt

user = systemaccount

password = systemaccount

delimiter = blank

overwrite = true

characterSet = blank

 

This is 9.05/Content Pack 9.

 

Any ideas?

Labels (1)
0 Likes
2 Replies
Absent Member.. Steve_Drummond Absent Member..
Absent Member..

Re: Creating an empty text file using FS Write Operation

Hi,

 

This should be pretty easy to workaround, although the answer may differ based on my query below.

 

Are you using the /lib/FileSystem/Windows Only/Write to File operation? I don't have a "COUNT" result on either the Windows or Cross Platform 'Write to File' operations and I'm running 9.05 CP9 as well. I only have a "COUNT" result on the 'Read File' operations.

 

Or are you using a "Line Count" result filter on the contents?

 

Are you sure the contents and delimiter inputs aren't inheriting a value from a previous variable? Although the 'Use Constant' may be blank that will be ignored if the 'assign from' variable actually has a value.

 

If you can give a little overview of what you're trying to achieve as well, any solution I can give will be better tailored.

 

cheers

steve

0 Likes
Absent Member.. bpscarbrough Absent Member..
Absent Member..

Re: Creating an empty text file using FS Write Operation

I figured it out.  It all has to do with the delimiters and characterSet usage. I used this to get it to work:

 

/Library/Operations/File System/Windows Only/Write to File

Inputs:

 

contents = nothing

delimiter = nothing

overwrite = true

characterSet = US-ASCII

 

This creates an empty text file.

 

Now, as my steps execute successfully I write a step number to this file using the /Library/Operations/File System/Windows Only/Write to File operation with these settings:

contents = "step number like 1 or 2 or 3...."

delimiter = "\n"

overwrite = false so it will append

characterSet = US-ASCII

 

To determine if step has successfully completed on future runs I use /Library/Operations/File System/Windows Only/Read File to read the file which returns COUNT for number of lines in the file.  I use logic to determine if the step has executed previously with success based on this COUNT.

 

This allows me to Run, Skip, or Force Skip a step for error handling.

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.