This is a simple AppleScript which check Apple's Mail app for unread messages and then outputs information.
For checkMail.scpt, from and subject is output for all unread emails.
For checkMailCount.scpt, only the total count of emails is returned, plus Email/Emails depending on the total count.
osascript /path/to/scripts/folder/checkMail.scpt