[GTALUG] Command doesn't work in script but works on command line?
John Sellens
jsellens at syonex.com
Sat Nov 6 13:45:54 EDT 2021
On Sat, 2021/11/06 01:32:13PM -0400, Kevin Cozens via talk <talk at gtalug.org> wrote:
| Modify the script to capture all output from the command as it may help you
| determine what may be going wrong when you run the command in a script.
| (e.g. >& messages.txt)
I'll echo Kevin's suggestion, and mention that potentially the output
of "printenv" might be informative, and I think you can capture everything
from a script by using (after the #! line)
exec >/tmp/output 2>&1
which I think sends all output of all following commands to /tmp/output.
I also try to check the result of commands in scripts and complain e.g.
alsa_out args ... \
|| echo 1>&2 "oh not alsa_out failed"
or
alsa_out args ...
ret=$?
if [ $ret -ne 0 ]; then
echo 1>&2 "alsa_out failed with $ret"
Hope that helps
John
More information about the talk
mailing list