Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There is a script which calls other scripts and they call others... I don't know exactly which scripts are called and how many of them. I only know that some of them are adding iptables rules and I get this error when I call root script.

iptables: No chain/target/match by that name.
iptables: No chain/target/match by that name.

My problem is that I can not find which script outputs this errors. Is there any way or tool to learn that?

share|improve this question
up vote 6 down vote accepted

You can trace the execution of a series of scripts using bash -x

bash -x /path/to/your/script

From this you can figure out which scripts are being called. You can force the script to abort early using the -e switch

bash -e -x /path/to/your/script

which may save you having to wade through lots of output

share|improve this answer

You can simply redirect stdout and sterr of the executed script to a file. Each script output can be directed to a separate file. In this case, you can look at these files and check which script returned an error.

To redirect output, you can use:

/path/to/script > /path/to/logfile.log

To redirect stdout and stderr, you can use:

/path/to/script > /path/to/logfile.log 2>&1

You can replace > with >> to append to the file instead of truncating it each time.

share|improve this answer
The OP has already stated "I don't know exactly which scripts are called and how many of them". – John Gardeniers Sep 4 '12 at 11:23
Even though, getting output from these scripts will be useful. – Khaled Sep 4 '12 at 11:34
That's perfectly true and in most cases is exactly what I would do. However, in this instance, redirecting each script to a separate file cannot be done because the scripts are unknown. – John Gardeniers Sep 4 '12 at 21:37

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.