2

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?

2 Answers 2

6

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

1

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.

3
  • 1
    The OP has already stated "I don't know exactly which scripts are called and how many of them". Sep 4, 2012 at 11:23
  • Even though, getting output from these scripts will be useful.
    – Khaled
    Sep 4, 2012 at 11:34
  • 1
    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. Sep 4, 2012 at 21:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .