Is there a way to do this? I mean without having a hidden mission beforehand that activates it?
Starting missions upon entering a system
As far as I'm aware, the only way to achieve this effect is to have a hidden mission that creates a ship in the system where you want the mission to kick off. Then, set the objective to "observe" and on ShipDone run the sXXX command. There are probably a few variations on this but I think that's the most straight-forward.