Skip to main content

I want to set all debugging output to a log file. So I checked https://askubuntu.com/questions/811439/bashcommand line -set bash: set -x-logs-to-file logs to file | Ask Ubuntu and followed the instructions.

test-script:

#!/bin/bash
exec 5 >/var/log/test.log
export BASH_XTRACEFD=5
main(){
set -x
echo hello
set +x
}
main

run:

./test-script

returns:

exec: 5: not found

The manual shows you can do this as well, so why is the above not working?

I want to set all debugging output to a log file. So I checked https://askubuntu.com/questions/811439/bash-set-x-logs-to-file and followed the instructions.

test-script:

#!/bin/bash
exec 5 >/var/log/test.log
export BASH_XTRACEFD=5
main(){
set -x
echo hello
set +x
}
main

run:

./test-script

returns:

exec: 5: not found

The manual shows you can do this as well, so why is the above not working?

I want to set all debugging output to a log file. So I checked command line - bash: set -x logs to file | Ask Ubuntu and followed the instructions.

test-script:

#!/bin/bash
exec 5 >/var/log/test.log
export BASH_XTRACEFD=5
main(){
set -x
echo hello
set +x
}
main

run:

./test-script

returns:

exec: 5: not found

The manual shows you can do this as well, so why is the above not working?

edited body
Source Link
e15purple
  • 33
  • 1
  • 1
  • 4

I want to set all debugging output to a log file. So I checked https://askubuntu.com/questions/811439/bash-set-x-logs-to-file and followed the instructions.

test-script:

!#!/bin/bash
exec 5 >/var/log/test.log
export BASH_XTRACEFD=5
main(){
set -x
echo hello
set +x
}
main

run:

./test-script

returns:

exec: 5: not found

The manual shows you can do this as well, so why isntis the above not working?

I want to set all debugging output to a log file. So I checked https://askubuntu.com/questions/811439/bash-set-x-logs-to-file and followed the instructions.

test-script:

!#/bin/bash
exec 5 >/var/log/test.log
export BASH_XTRACEFD=5
main(){
set -x
echo hello
set +x
}
main

run:

./test-script

returns:

exec: 5: not found

The manual shows you can do this as well, so why isnt the above working?

I want to set all debugging output to a log file. So I checked https://askubuntu.com/questions/811439/bash-set-x-logs-to-file and followed the instructions.

test-script:

#!/bin/bash
exec 5 >/var/log/test.log
export BASH_XTRACEFD=5
main(){
set -x
echo hello
set +x
}
main

run:

./test-script

returns:

exec: 5: not found

The manual shows you can do this as well, so why is the above not working?

Source Link
e15purple
  • 33
  • 1
  • 1
  • 4

Bash Script exec file descriptor returning "not found"

I want to set all debugging output to a log file. So I checked https://askubuntu.com/questions/811439/bash-set-x-logs-to-file and followed the instructions.

test-script:

!#/bin/bash
exec 5 >/var/log/test.log
export BASH_XTRACEFD=5
main(){
set -x
echo hello
set +x
}
main

run:

./test-script

returns:

exec: 5: not found

The manual shows you can do this as well, so why isnt the above working?