Detect script name

Prefer detecting script name to assuming script name.