-1

I would like to know if you have a file name > abc (1).bin or > abc (1).txt files, how do you read them. The files are with the space and bracket before the .bin or .txt extension.

To read the .bin file I have a tool, I can read it easily if I remove the "space and (1)" from the filename. But when I have this space and bracket (1).bin name, I can not read it.

When I cat a .txt file, it works.. but it doesn't work with the .bin file. Below are the requested tests:

$ cat full_logs-10.2.0.103-2018.02.07\ \(1\).txt 
hello,
this is a test.

--------xxxxxxx------xxxxxxx------------xxxxxxx--------

$ LogAnalyzeRebirth -p -x ./ full_logs-2018.02.07\ \(1\).bin 
usage: LogAnalyzeRebirth [-h] [-A] [-B] [-C] [-D] [-E] [-F]
                         [-G GRAPH [GRAPH ...]] [-H] [-I [HISTOGRAM]] [-L]
                         [-M] [-N] [-P [PDF]] [-R] [-S] [-T] [-U] [-V] [-b]
                         [-c] [-e] [--moo] [-f] [-g] [-i] [-k] [-l] [-m] [-n]
                         [-o] [-p PATH] [-q] [-r] [-s] [-t] [-v] [-x EXTRACT]
                         [-z]
LogAnalyzeRebirth: error: argument -p/--path: expected 1 argument(s)

--------xxxxxxx------xxxxxxx------------xxxxxxx--------

$ LogAnalyzeRebirth.py -p ./ -x "full_logs-10.2.0.103-2018.02.07 (1).bin" 

(\ /)                      (\ /)
( . .)      LogAnalyzeRebirth     (. . )
c(")(")                  (")(")o

sh: 1: Syntax error: "(" unexpected
sh: 1: Syntax error: "(" unexpected
sh: 1: Syntax error: "(" unexpected
Extract failed.
LogAnalyzeRebirth can't find full_logs-10.2.0.103-2018.02.07 (1).bin
No such file or directory : ./full_logs-10.2.0.103-2018.02.07 (1)/dmesg

---   Firmware_version   ---

No such file or directory : ./full_logs-10.2.0.103-2018.02.07 (1)/version.txt

--------xxxxxxx------xxxxxxx------------xxxxxxx--------
David Foerster
  • 36,890
  • 56
  • 97
  • 151
Imrank
  • 51

1 Answers1

0

The discussion in the comments showed that the weird filename has to be passed to a script or program which itself is calling other scripts or programs with the filename as a parameter. Therefore enclosing the filename in quotes is not sufficient as the shell removes these quotes and the next call transmits the filename without quotes, making it unusable.

So my idea is to use a wrapper script doLogAnalyze for LogAnalyzeRebirth.py, like this:

#!/bin/bash
tmpfile=$(mktemp /tmp/LogAnalyzeRebirth.XXXXXX) # create temporary file
cp "$1" "$tmpfile"                              # copy to temporay file
LogAnalyzeRebirth.py -p ./ -x "$tmpfile"        # analyze copy
rm "$tmpfile"                                   # delete copy

Calling ./doLogAnalyze "full_logs-10.2.0.103-2018.02.07 (1).bin" should do the job, regardless of how many other programs are used within the main program. No change is made to the original files, as was the wish of the OP.

muclux
  • 5,324