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.