My plan is to write a script to debug a remote web server.
Since the debug port is blocked by the firewall, I need to forward the remote port via ssh to my local machine. This part is working fine.
The command to run the server in debug mode blocks the terminal. So when I hit CTRL C the server should be stopped. However I want the server to be started again in normal mode, when I am done with debugging. So I added a trap command.
This is my current approach:
ssh -tt my.server -L 8001:localhost:8000 <<'ENDSSH'trap 'start server as service in normal mode' 2stop serverstart server in debug modeENDSSH
However, when I hit CTRL C, the ssh connection is terminated and the command inside the trap is not executed.
Complete scripting newbie here. Need help.