Skip to main content
1-Visitor
September 30, 2013
Solved

Detect if is binary or text ?

  • September 30, 2013
  • 1 reply
  • 5226 views

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).

    Best answer by jgorsline

    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.

    1 reply

    1-Visitor
    September 30, 2013

    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

    1-Visitor
    September 30, 2013

    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

    jgorsline1-VisitorAnswer
    1-Visitor
    October 2, 2013

    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.