Make sure CLI scripts are only being run from the CLI

Bug 1387903

Change-Id: I369d58f85c944f4be2bc2965c080b2c4c86dadc1