0

I want to create a log file whilst my script extracts 7z

I'm using the following:

7z x "*.7z" >> logfile.log 2>&1

But terminal stops displaying output and the log file is blank...

mklement0
  • 382,024
  • 64
  • 607
  • 775
NeMesiS
  • 59
  • 1
  • 5

2 Answers2

0

Probably the 7z program is detecting that its stdout is not a terminal (TTY), and is choosing not to be so verbose in this case.

Unfortunately, the 7z documentation doesn't seem to offer a "verbose" flag like many programs do. So I'm not sure you can turn the output on easily.

But you can trick the program into thinking it has a terminal on stdout! For example:

script logfile.log 7z x "*.7z"

For more ideas, see: Bash: trick program into thinking stdout is an interactive terminal

Community
  • 1
  • 1
John Zwinck
  • 239,568
  • 38
  • 324
  • 436
0

You're redirecting STDERR to STDOUT (that's the 2>&1) and redirecting STDERR to the logfile. Try 7z x "*.7z" 2>&1 > logfile.log. Hope that helps:

% 7z c /tmp/TailsBSDPLIST.7z ~/TailsBSD > /tmp/logfile.log
% cat /tmp/logfile.log
7-Zip (a) 9.38 beta Copyright (c) 1999-2014 Igor Pavlov 2015-01-03 p7zip Version 9.38.1 (locale=C,Utf16=off,HugeFiles=on,1 CPU)

Command Line Error: Unsupported command: c

hd1
  • 33,938
  • 5
  • 80
  • 91