Hello coutoj,
Issuing the no shut command allows a port to be used that is it can become up/up if the port becomes up/down not connected it is likey because nothing is connected to the port or the device connected to the port has fixed settings of speed and duplex that does not allow to build a working link.
You should look at all cases of failures and see if there is anything in common (type of device on the other side of the link for example).
Collect all this info and analyze it.
The script can check the interface status after issuing the no shut and it can record all the failures but I don't see much more it can do by itself.
Hope to help
Giuseppe
Hope to help
Giuseppe