Unsolved Redirecting feedback from Linux command
-
So, normal output is redirected to my log file.
But this status bar that pops up on the bottom of the screen when you manually upgrade still shows on the screen.
As I am using a script to perform all of this, I would rather not see this.
Said Script: https://gitlab.com/bundyassociates/freepbx-scripts/setup-scripts/-/blob/master/setup.shHow do I determine what output this status bar is?
-
Trial and error led me to determine that it is
stderr
.That is annoying as hell. One would assume that actual errors I may want to see show up there also.
I don't want that in the logfile or on my screen. but I do want actual errors.
-
This makes it not show up anyplace.
printf "Upgrading all installed modules...\n" | tee -a $logfile fwconsole ma upgradeall 2> /dev/null >> $logfile
Redirecting 2, which is
stderr
, to/dev/null
while appending the rest to the logfile>> $logfile
. -
@JaredBusch said in Redirecting feedback from Linux command:
Trial and error led me to determine that it is
stderr
.That is annoying as hell. One would assume that actual errors I may want to see show up there also.
I don't want that in the logfile or on my screen. but I do want actual errors.
stderr
is for both diagnostics and errors so I guess one could argue that it's diagnostics. Otherwise it's bad form for a developer to print anything to stderr that doesn't belong there.I suggest piping
stderr
to a file instead of /dev/null. Then you can examine the file. Determine what you don't want to end up instderr
. Then when you runfwconsole
you can pipestderr
togrep
and remove what you don't want. -
@Pete-S said in Redirecting feedback from Linux command:
Then when you run fwconsole you can pipe stderr to grep and remove what you don't want.
Something like this should do the trick:
fwconsole ma upgradeall 1>> $logfile2 2> >(grep -v what_you_don't_want >&2)
- stdout is appended to the $logfile2 with
1>> $logfile2
- stderr is output with process substitution to grep with
2> >(grep bla bla bla)
which then pipes it's output back to stderr with>&2
- stdout is appended to the $logfile2 with
-
@Pete-S Pretty much what I do not want is the status bar from these two commands.
fwconsole ma upgradeall
fwconsole chown
-
@JaredBusch said in Redirecting feedback from Linux command:
@Pete-S Pretty much what I do not want is the status bar from these two commands.
fwconsole ma upgradeall
fwconsole chown
Well, use grep to match for the progress bar then.
First output
stderr
to a file and look in the file.I don't know how the progress bar looks when it's output as a stream of characters.
I'm guessing every update is something like3076094/3076094 [===========>-------------] 60%<CR>
In that case
grep
for every line that doesn't contain a[
followed by a number of=
,>
or-
and finally a]
.So something like:
grep -v '[[=->]+\]'
Or maybe even better:
grep -v '[[=->]{28}\]'
Above assuming there are always 28 characters inside the brackets in the progress bar.
PS.
Funny thing but there seems to be a bug in the forum software.
I had to use an extra backslash to get the above regex look right[[=->]+\\]
instead of[[=->]+\]
They look right in the preview though.