Why does the filename contain question marks when I run a script on my remote machine?
You probably have some non-printable characters on end of lines (eg. CRLF from Windows), run:
cat -A scriptname
on remote machine, it'll show you all characters in your script. Then, you can convert to unix-like format running
dos2unix scriptname
Found Notepad ++ to be very useful for correcting this after attempting the answer
cat -A scriptname>
dos2unix scriptname
as this still presented errors when trying to convert.
Through Notepad ++ there's the option in the edit menu/EOL Conversion/Unix/OSX Format.
Still very much a learner but this method solved my problem, however the previous solution assisted in finding where the problem was.