Hans
Hans

Reputation: 591

preventing scripts from stopping on errors

My issue is likely a rather simple one, I just haven't found a satisfactory answer anywhere I've looked so far.

I have a script which runs a program/script, when it encounters an error it just hangs and will not continue along. What is the best method to fix this?

To clarify, usually there is no output when it hangs but sometimes there is an error message, depending on which script I am using to work on my data set.

Example script:

#!/bin/bash
# iterate over a NUL-delimited stream of directory names
while IFS='' read -r -d '' dirname; do
  # ...then list files in each directory:
  for file in "$dirname"/*; do
    # ignore directory contents that are not files
    [[ -f $file ]] || continue
    # run analysis tool
    if [[ $file == *.dmp ]]; then
      echo $dirname;
      tshark -PVx -r "$file" >> $dirname/TEXT_out.txt #with packet summary line, packet details expanded, packet bytes
      #ls $dirname;
      echo "complete";
      continue
    fi
  done
done < <(find . -type d -print0)

Upvotes: 0

Views: 50

Answers (1)

kumar_m_kiran
kumar_m_kiran

Reputation: 4022

In nutshell, you are asking - how to handle if the child process hangs (from parent perspective). If that is the basic issue your are facing, then you can check this link. HTH!

Upvotes: 1

Related Questions