Thanks a lot! I had a suspicion the issue was something like this.
This is extremely inconvenient though, since now I have to change quite
a few scripts, more importantly now I also have to figure out the
machine my script is running on (e.g. laptop or institutes servers).
I guess switching to nmap might resolve the second issue.
You could test if the package installed is netcat (or was it called nc?) or
nmap-ncat and then execute as appropriate in your script.