Jump to content




"unexpected symbol" error


7 replies to this topic

#1 RedNeckSnailSpit

  • Members
  • 14 posts
  • LocationSouth Africa

Posted 12 May 2017 - 03: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!

#2 H4X0RZ

  • Members
  • 1,315 posts
  • LocationGermany

Posted 12 May 2017 - 03:25 PM

You are missing the brackets for .close on line 12

#3 RedNeckSnailSpit

  • Members
  • 14 posts
  • LocationSouth Africa

Posted 12 May 2017 - 03:40 PM

View PostH4X0RZ, on 12 May 2017 - 03:25 PM, said:

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:

View PostRedNeckSnailSpit, on 12 May 2017 - 03:18 PM, said:

"bios:14: [string "AuthKeyServer"]:1: unexpected symbol"


#4 Emma

  • Members
  • 216 posts
  • Locationtmpim

Posted 12 May 2017 - 06: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 by Incinirate, 12 May 2017 - 06:31 PM.


#5 RedNeckSnailSpit

  • Members
  • 14 posts
  • LocationSouth Africa

Posted 12 May 2017 - 06:48 PM

View PostIncinirate, on 12 May 2017 - 06:29 PM, said:

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.

#6 RedNeckSnailSpit

  • Members
  • 14 posts
  • LocationSouth Africa

Posted 12 May 2017 - 09: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.

#7 Emma

  • Members
  • 216 posts
  • Locationtmpim

Posted 13 May 2017 - 03: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.

#8 GhastTearz

  • Members
  • 6 posts

Posted 13 May 2017 - 08: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





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users