Menu

#66 Using a quoted attachmentfilename -> further files in list not attached

v1.0 (example)
open
nobody
None
5
2022-08-04
2022-07-20
RB
No

If you quote a filename for an attachment (e.g. ,leadingComma.txt) and separated by a comma there are more files, then the remaining files are not attached

-attach ",leadingComma.txt",normal.txt

(here the file named normal.txt is ignored)

As a workaround you can use the option -attach for every file seperatly on the commandline.
-attach ",leadingComma.txt" -attach normal.txt

-

Below the listing of the used test-directory

 Verzeichnis von C:\Temp\blat_whitespace

2022-07-20  10:55    <DIR>          .
2022-07-20  10:55    <DIR>          ..
2022-07-20  06:44               410  leadingSpace.txt
2022-07-20  06:44               354 ,leadingComma.txt
2022-07-20  11:03             1.166 b.cmd
2019-07-19  23:25           356.864 blat.exe
2022-07-20  10:55               607 normal.txt
2022-07-20  07:39                 7 trailingSpace.txt
               6 Datei(en),        359.408 Bytes

The content of the testbatch (three " on the commandline makes one " for the program)

REM @ECHO OFF
SETLOCAL

SET LOG=C:\Temp\blatlog.txt

cls

REM normal_file
@SET OPTS=-log %LOG% -timestamp -server localhost -f from@localhost.local -t To@localhost.local -Subject Test
DEL %LOG% && TYPE b.cmd | Blat.exe %OPTS% -attach normal.txt
@ECHO RETURNCODE: %ERRORLEVEL% && TYPE %LOG%

REM normal_file + quotedfile
@SET OPTS=-log %LOG% -timestamp -server localhost -f from@localhost.local -t To@localhost.local -Subject Test
DEL %LOG% && TYPE b.cmd | Blat.exe %OPTS% -attach normal.txt,""",leadingComma.txt"""
@ECHO RETURNCODE: %ERRORLEVEL% && TYPE %LOG%

REM quotedfile + normal file -> NOT NOT attached the normal_file
@SET OPTS=-log %LOG% -timestamp -server localhost -f from@localhost.local -t To@localhost.local -Subject Test
DEL %LOG% && TYPE b.cmd | Blat.exe %OPTS% -attach """,leadingComma.txt""",normal.txt
@ECHO RETURNCODE: %ERRORLEVEL% && TYPE %LOG%

REM file with trailing space -> NOT attached
@SET OPTS=-log %LOG% -timestamp -server localhost -f from@localhost.local -t To@localhost.local -Subject Test
DEL %LOG% && TYPE b.cmd | Blat.exe %OPTS% -attach """trailingSpace.txt """
@ECHO RETURNCODE: %ERRORLEVEL% && TYPE %LOG%

Testbatchoutput

C:\Temp\blat_whitespace>REM @ECHO OFF 

C:\Temp\blat_whitespace>SETLOCAL

C:\Temp\blat_whitespace>SET LOG=C:\Temp\blatlog.txt 

C:\Temp\blat_whitespace>cls

C:\Temp\blat_whitespace>REM normal_file 

C:\Temp\blat_whitespace>DEL C:\Temp\blatlog.txt   && TYPE b.cmd   | Blat.exe -log C:\Temp\blatlog.txt -timestamp -server localhost -f from@localhost.local -t To@localhost.local -Subject Test -attach normal.txt 
Blat v3.2.22 (build : Jul 19 2019 23:25:54)
64-bit Windows, Full, Unicode

RETURNCODE: 0 
´╗┐
2022.07.20 11:14:10 (Wed)------------Start of Session-----------------
Blat v3.2.22 (build : Jul 19 2019 23:25:54)
64-bit Windows, Full, Unicode
2022.07.20 11:14:10 (Wed): Sending stdin.txt to To@localhost.local
2022.07.20 11:14:10 (Wed): Subject: Test
2022.07.20 11:14:10 (Wed): Login name is from@localhost.local
2022.07.20 11:14:10 (Wed): Attached binary file: normal.txt
2022.07.20 11:14:10 (Wed)-------------End of Session------------------

C:\Temp\blat_whitespace>REM normal_file + quotedfile 

C:\Temp\blat_whitespace>DEL C:\Temp\blatlog.txt   && TYPE b.cmd   | Blat.exe -log C:\Temp\blatlog.txt -timestamp -server localhost -f from@localhost.local -t To@localhost.local -Subject Test -attach normal.txt,""",leadingComma.txt""" 
Blat v3.2.22 (build : Jul 19 2019 23:25:54)
64-bit Windows, Full, Unicode

RETURNCODE: 0 
´╗┐
2022.07.20 11:14:10 (Wed)------------Start of Session-----------------
Blat v3.2.22 (build : Jul 19 2019 23:25:54)
64-bit Windows, Full, Unicode
2022.07.20 11:14:10 (Wed): Sending stdin.txt to To@localhost.local
2022.07.20 11:14:10 (Wed): Subject: Test
2022.07.20 11:14:10 (Wed): Login name is from@localhost.local
2022.07.20 11:14:10 (Wed): Attached binary file: normal.txt
2022.07.20 11:14:10 (Wed): Attached binary file: ,leadingComma.txt
2022.07.20 11:14:10 (Wed)-------------End of Session------------------

C:\Temp\blat_whitespace>REM quotedfile + normal file -> NOT NOT attached the normal_file 

C:\Temp\blat_whitespace>DEL C:\Temp\blatlog.txt   && TYPE b.cmd   | Blat.exe -log C:\Temp\blatlog.txt -timestamp -server localhost -f from@localhost.local -t To@localhost.local -Subject Test -attach """,leadingComma.txt""",normal.txt 
Blat v3.2.22 (build : Jul 19 2019 23:25:54)
64-bit Windows, Full, Unicode

RETURNCODE: 0 
´╗┐
2022.07.20 11:14:10 (Wed)------------Start of Session-----------------
Blat v3.2.22 (build : Jul 19 2019 23:25:54)
64-bit Windows, Full, Unicode
2022.07.20 11:14:10 (Wed): Sending stdin.txt to To@localhost.local
2022.07.20 11:14:10 (Wed): Subject: Test
2022.07.20 11:14:10 (Wed): Login name is from@localhost.local
2022.07.20 11:14:10 (Wed): Attached binary file: ,leadingComma.txt
2022.07.20 11:14:11 (Wed)-------------End of Session------------------

C:\Temp\blat_whitespace>REM file with trailing space -> NOT attached 

C:\Temp\blat_whitespace>DEL C:\Temp\blatlog.txt   && TYPE b.cmd   | Blat.exe -log C:\Temp\blatlog.txt -timestamp -server localhost -f from@localhost.local -t To@localhost.local -Subject Test -attach """trailingSpace.txt """ 
Blat v3.2.22 (build : Jul 19 2019 23:25:54)
64-bit Windows, Full, Unicode

RETURNCODE: 12 
´╗┐
2022.07.20 11:14:11 (Wed)------------Start of Session-----------------
Blat v3.2.22 (build : Jul 19 2019 23:25:54)
64-bit Windows, Full, Unicode
2022.07.20 11:14:11 (Wed): No files found matching search string "trailingSpace.txt ".
2022.07.20 11:14:11 (Wed): One or more attachments had not been found.
Aborting, so you find / fix the missing attachment.
2022.07.20 11:14:11 (Wed)-------------End of Session------------------

Discussion

  • Chip

    Chip - 2022-07-21

    Another option might be -attach "ing.tx*" with your example directory list. Commas and spaces in filenames present problems with parsing, because the C programming language uses these two for its own internal command line parsing.

    The asterisks that I used should give you all three of your special case files.

     
  • RB

    RB - 2022-07-21

    Another option might be -attach "ing.tx*" with your example directory list.

    Not adressing the actual problem but yes it runs (even quoted!).
    It seems, that blat has its own routine to collect files from using filenamepatterns (cmp. attach.cpp -> collectAttachmentInfo using Win-API -> FindFirst/FindNext)

    Commas and spaces in filenames present problems with parsing, because the C programming language uses these two for its own internal command line parsing.
    Not C, but the startupcode of the used C-runtimelibrary.

    The asterisks that I used should give you all three of your special case files.
    Yes and thanks for the hint

    C:\Temp\blat_whitespace>DEL C:\Temp\blatlog.txt   && TYPE b.cmd   | Blat.exe -log C:\Temp\blatlog.txt -timestamp -server localhost -f from@localhost.local -t To@localhost.local -Subject Test -attach """*.txt"""
    Blat v3.2.22 (build : Jul 19 2019 23:25:54)
    64-bit Windows, Full, Unicode
    
    RETURNCODE: 0 
    ´╗┐
    2022.07.21 07:52:20 (Thu)------------Start of Session-----------------
    Blat v3.2.22 (build : Jul 19 2019 23:25:54)
    64-bit Windows, Full, Unicode
    2022.07.21 07:52:20 (Thu): Found "trailingSpace.txt " matching search string "*.txt", but the file cannot be opened.
    2022.07.21 07:52:20 (Thu): Sending stdin.txt to To@localhost.local
    2022.07.21 07:52:20 (Thu): Subject: Test
    2022.07.21 07:52:20 (Thu): Login name is from@localhost.local
    2022.07.21 07:52:20 (Thu): Attached binary file:  leadingSpace.txt
    2022.07.21 07:52:20 (Thu): Attached binary file: ,leadingComma.txt
    2022.07.21 07:52:20 (Thu): Attached binary file: normal.txt
    2022.07.21 07:52:20 (Thu)-------------End of Session------------------
    
     
  • RB

    RB - 2022-07-25

    Attached a short description how I fixed the error for me. Would be nice, if this correction could be integrated into the repository.

     
  • Chip

    Chip - 2022-07-29

    The fix you proposed for version 3.2.22 has already been incorporated into version 3.2.23 and beyond.

    The 32-bit full version 3.2.24 is here:
    https://app.box.com/s/sbqywrd5phmhxxtbi9u2csvcz18hywrt

    The 64-bit full version 3.2.24 is here:
    https://app.box.com/s/zh28oqn03dlnqcez54m92al9om9seual

    I will upload the files to SourceForge this weekend.

     
  • RB

    RB - 2022-08-02

    Using the Version 3.2.24 the fix incorporated in 3.2.23 works.
    Please close this ticket (I cannot do that ?)

     
  • Chip

    Chip - 2022-08-03

    I cannot close the ticket, either.

     
  • RB

    RB - 2022-08-04

    I asked the support.
    Answer below;

    Hello,
    
    Only the administrative users of the project can close the ticket.
    
    
    Sincerely,
    
    SourceForge Support!
    

    Anyway
    Thank you for the binaries 3.2.24

     

Log in to post a comment.

MongoDB Logo MongoDB