ksh case statement issue

Hi. I wrote the following case statement to replace a series of 'ELIF' statements as it looks better and is easier to maintain. However, for some reason the commands don't fully work in this format. Take option 1. It should call a script that runs in the background but it doesn't work. Can anyone see what I'm doing wrong?
Many thanks.

case ${_OPTION} in
                  1) print "Running option 1: $file\n"; $(nohup ${BASE}/run_test ${file} > /dev/null 2>&1 &) ; _RC=$? ; [[ $_RC -ne 0 ]] && exit 1
                        ;;
                  2) print "Running option 2: $file\n"; ${BASE}/run_test ${file}; _RC=$?; [[ $_RC -ne 0 ]] && exit 1
                        ;;
                  3) print "Running option3"
                        ;;
                  *)
                        print "[ERROR] Invalid number specified. Exiting ...\n "; exit 1
                esac
1) print "Running option 1: $file\n"; { nohup ${BASE}/run_test ${file} > /dev/null 2>&1 ; } & ; _RC=$? ; [[ $_RC -ne 0 ]] && exit 1";";";
1 Like

... or perhaps this:-

                  1) print "Running option 1: $file\n"; (nohup ${BASE}/run_test ${file} > /dev/null 2>&1) & _RC=$? ; [[ $_RC -ne 0 ]] && exit 1

I've dropped the leading $ from $(nohup and changed the trailing &) ; to be ) &

I assume that you just want to know that the task launched in the background successfully, not that the task finished successfully.

Robin

2 Likes

Thanks guys. Both methods worked!