Home > Software engineering >  130:132: syntax error: Expected end of line, etc. but found real number. (-2741)
130:132: syntax error: Expected end of line, etc. but found real number. (-2741)

Time:11-13

#!/bin/bash

printf 'Starting Text Script... \nWhat number would you like to text?\n'
read number

msg="When..."
/usr/bin/osascript - "$@" << END
tell application "Messages" to send "$msg" to buddy "$number" 
END
sleep .1

msg="Cause..."
/usr/bin/osascript - "$@" << END
tell application "Messages" to send "$msg" to buddy "$number" 
END                         
sleep .1

msg="Laughing..."
/usr/bin/osascript - "$@" << END
tell application "Messages" to send "$msg" to buddy "$number" 
END
sleep .1

msg="Like..."
/usr/bin/osascript - "$@" << END
tell application "Messages" to send "$msg" to buddy "$number" 
END
sleep .1

this is the beginning of a script that sends a series of messages to an inputted number (just a script for fun to mess with a friend a bit). For some reason, the 1st message and every message at and after the 4th message; but the 2nd and 3rd message do not send and I get the listed error. I am confused since they are all written the same and only those two fail. I don't have much experience with apple scripts, so I am sure my error is somewhere in there.

I initially had the second value of msg set to "'Cause...", but I thought that's what was causing my error so I removed it. I am also thinking about having the script take input of a number and filepath instead and then reading each line of the file as a separate msg to send, but I am not positive how to achieve that. Any and all help is greatly appreciated!

CodePudding user response:

Remove all white spaces after END.

CodePudding user response:

There was trailing white space on the closing on line 15 of the script. Not sure how it got there haha.

  • Related