This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
RedNeckSnailSpit's profile picture

"unexpected symbol" error

Started by RedNeckSnailSpit, 12 May 2017 - 02:18 PM
RedNeckSnailSpit #1
Posted 12 May 2017 - 04:18 PM
Hi! I'm writing a proof of concept script. The code is below, but I keep getting the error "bios:14: [string "AuthKeyServer"]:1: unexpected symbol"

code: https://pastebin.com/mGUecsv8

What the script is supposed to do is allow users to log in without a password. It uses the computer's ID as the user's key, meaning only that PC can log you in. To authorise a PC, the server needs to generate a key for the user. The user can use that to log in the first time, then they no longer need to use a password to log in. The code above is the server side of things.

I was inspired by this Ask A Pro thread and the linux passwordless login system.

I'm 90% sure I'm gonna kick myself when I figure out/find out what the problem is.

Thanks, pros!
H4X0RZ #2
Posted 12 May 2017 - 04:25 PM
You are missing the brackets for .close on line 12
RedNeckSnailSpit #3
Posted 12 May 2017 - 04:40 PM
You are missing the brackets for .close on line 12

Well, that was an error on my part, but it still didn't fix the error I'm currently getting. Still getting the same error here:

"bios:14: [string "AuthKeyServer"]:1: unexpected symbol"
Emma #4
Posted 12 May 2017 - 07:29 PM
Also in Lua strings, you can escape characters using the \ character. In your fs calls, you write something like this

userFile = fs.open("authIDs\".. pcID, "r")
So in this case you escape the " character with the backslash meaning that it doesn't actually close the string and instead becomes part of it, so all your code gets messed up, either replace all of the \ characters with a forward slash (/) as it has the same meaning in the context of the filesystem, or replace them with a double backslash \\ so that it escapes itself and the backslash is actually part of the string as a backslash.
Like this:

userFile = fs.open("authIDs/".. pcID, "r") -- this one is better imo
-- or like this
userFile = fs.open("authIDs\\".. pcID, "r")
Edited on 12 May 2017 - 05:31 PM
RedNeckSnailSpit #5
Posted 12 May 2017 - 07:48 PM
Also in Lua strings, you can escape characters using the \ character. In your fs calls, you write something like this

userFile = fs.open("authIDs\".. pcID, "r")
So in this case you escape the " character with the backslash meaning that it doesn't actually close the string and instead becomes part of it, so all your code gets messed up, either replace all of the \ characters with a forward slash (/) as it has the same meaning in the context of the filesystem, or replace them with a double backslash \\ so that it escapes itself and the backslash is actually part of the string as a backslash.
Like this:

userFile = fs.open("authIDs/".. pcID, "r") -- this one is better imo
-- or like this
userFile = fs.open("authIDs\\".. pcID, "r")

Well, that would explain a lot. I'm used to AutoHotkey where I place \ instead of / when working with a local directory, so I did the same with lua :/

Thanks! I've changed the code, I'll try it again in a sec.
RedNeckSnailSpit #6
Posted 12 May 2017 - 10:20 PM
I fixed all the errors both of you guys mentioned, and still got the same error, but I managed to fix it:

All I did was take each section of code one-by-one and paste it in a new file. I then ran the file, checked for errors, and added the next bit, and so on.

As it turned out, there where more bugs in that code than there are in BF3. Eventually I ironed out all the bugs, and I ran the new file just fine. I copied the code exactly as is from the new file to the old file, aaaaand I got the old error again. Really weird, since I copied the working code exactly as is - no alterations at all. I ran the code again on both files (exact same code) and the one worked fine, while the other gave an error. Really weird. So I renamed the old file (The one giving errors) and tried again - same result. One errored, one not. So I deleted the errored file and renamed the new file to exactly the same as the errored file - and it worked just fine.

So no idea what was causing that error, but the code has been fixed.

Thanks guys! I've posted here code here in the Programs section. Might not be able to see it until it gets approved.
Emma #7
Posted 13 May 2017 - 04:49 AM
Glad you got it working! My suspicion is that there was a weird unwanted invisible character on the very first line that you couldn't tell was there or something. Very strange though.
GhastTearz #8
Posted 13 May 2017 - 09:50 AM
Most of your errors are forgeting parens, using backslashes ( which escape the charecter following it), and calling send instead of rednet.send.
I know you didn't ask for it, but I rewrote your code to be more readable. I hope its a good example for you to write better code so you won't
have to spend lots of time getting help online. It should work, but I couldn't test it because you havent posted your client code. Anyways the link
to my revision is here: https://pastebin.com/qbKA4urW