Skip to main content
deleted 11 characters in body
Source Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265

How are you? My script looks like:

trap "$(pwd)/dd-destroy.sh $l-env;$(pwd)/dd-drop.sh $l-db;exit" INT QUIT TERM EXIT

./dd-all.sh $l $l-db $l-env || exit 1

app_ip=$(./dd-status.sh ip $l-env|grep docker-app|awk '{print $3}')
url=http://$app_ip:8080/app/

wget -O /dev/null $url || (echo "access $url failed" && false) || exit 1

Now I want this trap launch when error occurs, those 'exit 1' (I can change them there). But when nothing happens, like dd-all.sh worked fine, when wget came fine. I do not wannawant to call for destroy.

Can I accomplish this with trap? It's not my script, I need to change it a little. Maybe trap is a bad call here?

How are you? My script looks like:

trap "$(pwd)/dd-destroy.sh $l-env;$(pwd)/dd-drop.sh $l-db;exit" INT QUIT TERM EXIT

./dd-all.sh $l $l-db $l-env || exit 1

app_ip=$(./dd-status.sh ip $l-env|grep docker-app|awk '{print $3}')
url=http://$app_ip:8080/app/

wget -O /dev/null $url || (echo "access $url failed" && false) || exit 1

Now I want this trap launch when error occurs, those 'exit 1' (I can change them there). But when nothing happens, like dd-all.sh worked fine, when wget came fine. I do not wanna call for destroy.

Can I accomplish this with trap? It's not my script, I need to change it a little. Maybe trap is a bad call here?

My script looks like:

trap "$(pwd)/dd-destroy.sh $l-env;$(pwd)/dd-drop.sh $l-db;exit" INT QUIT TERM EXIT

./dd-all.sh $l $l-db $l-env || exit 1

app_ip=$(./dd-status.sh ip $l-env|grep docker-app|awk '{print $3}')
url=http://$app_ip:8080/app/

wget -O /dev/null $url || (echo "access $url failed" && false) || exit 1

Now I want this trap launch when error occurs, those 'exit 1' (I can change them there). But when nothing happens, like dd-all.sh worked fine, when wget came fine. I do not want to call for destroy.

Can I accomplish this with trap? It's not my script, I need to change it a little. Maybe trap is a bad call here?

Source Link

Skip 'natural' exit in trap

How are you? My script looks like:

trap "$(pwd)/dd-destroy.sh $l-env;$(pwd)/dd-drop.sh $l-db;exit" INT QUIT TERM EXIT

./dd-all.sh $l $l-db $l-env || exit 1

app_ip=$(./dd-status.sh ip $l-env|grep docker-app|awk '{print $3}')
url=http://$app_ip:8080/app/

wget -O /dev/null $url || (echo "access $url failed" && false) || exit 1

Now I want this trap launch when error occurs, those 'exit 1' (I can change them there). But when nothing happens, like dd-all.sh worked fine, when wget came fine. I do not wanna call for destroy.

Can I accomplish this with trap? It's not my script, I need to change it a little. Maybe trap is a bad call here?