Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
Hello,
There is any CLI command in MKS Integrity 9.6 for detect if a new member must be added as binary instead of text ?
Some files are automatically detected as binary when you try to add them as text (e.g. doc, pdf) if contains null characters and have lines longer than 16 kB (have line terminators separated by more than 16 kB within the file).
Solved! Go to Solution.
There is not a function built into the Integrity CLI that allows you to determine if a file is binary or ASCII. On Unix based systems and WIndows systems with MKS Toolkit installed the 'file' command can be used to determine the type of file. For example:
>file name.txt
name.txt: ASCII text
>file name2.jpg
name2.jpg: JPEG image - JFIF format
While this is not integrated into the Integrity CLI, this could easily be automated in a batch file or shell script to check the file type and run the add command with the desired flags.
Hi Dany
I am not sure if there is a mechanism to check before the file is added, but at the time you are adding the file with "si add", you can use --binaryFormat or --textFormat to force the file to be added as binary or text, respectively.
Hope that helps,
Matt
I need something to use before “si add” command, something able to tell me in an automated script that the new member must be added as binary and not as text.
Let assume we try in an automated sequence to add for example a MS Word file (test.doc) by using command si add --cpid=... --nocloseCP --onExistingArchive=sharearchive --description=my_description --sandbox=”...mysandbox/project.pj” “…/…/test.doc” with no data type argument mentioned (like “auto” mode for data type in MKS client GUI).
MKS client detects test.doc as binary and automatically add this new member as binary archive, even if I didn't used “--binaryFormat” argument in cmd line.
I want to know if there is any tool/command capable to tell me that I need to use “--binaryFormat” instead of “—textFormat” in a similar way with existing mechanism implemented in MKS client.
Thanks
There is not a function built into the Integrity CLI that allows you to determine if a file is binary or ASCII. On Unix based systems and WIndows systems with MKS Toolkit installed the 'file' command can be used to determine the type of file. For example:
>file name.txt
name.txt: ASCII text
>file name2.jpg
name2.jpg: JPEG image - JFIF format
While this is not integrated into the Integrity CLI, this could easily be automated in a batch file or shell script to check the file type and run the add command with the desired flags.
Thanks Jeremy for useful answer.
We can use this utility from MKS toolkit or similar distributions like msys from MinGW.
Can you confirm that MKS client works in the same way like file utility when add new members in "auto" mode.
I mean, if you don't specify data type (text/binary) the client performs an internal test similar with file.exe utility and if input is ASCII it will be added as 'text' otherwise as binary?
I can confirm that Integrity uses a similar test to determine if a file is binary or ASCII. I should note that it doesn't use the exact same method, so there is the slim possibility that the file command could mark a file differently than Integrity, especially if the user has made manual additions to the magic file.
In most circumstances, it should be safe to assume that the file command and Integrity will determine a file is the same type.