Detect script name

Prefer detecting script name to assuming script name.
Merge pull request #32 from Bilge/patch-1

Detect script name