Jump to content




[Error] http.get '=' expected


  • You cannot reply to this topic
10 replies to this topic

#1 Simon

  • Members
  • 58 posts
  • LocationSeattle

Posted 04 March 2013 - 10:15 AM

I have no idea...

bios:338: [string "paste"]:6: '=' expected


local tArgs = { ... }
local sCode = tArgs[1]
local sFile = tArgs[2]
local sPath = shell.resolve( sFile )

local response = http.get("http://pastebin.com/raw.php?i=" ..sCode)

if response then
failed = false
local sResponse = response.readAll()
response.close()

local file = fs.open( sPath, "w" )
file.write( sResponse )
file.close()
print( "Downloaded as "..sFile )

else
print( "Failed." )
failed = true
fail()
end

failed and fail are already created in the startup program btw

Thanks in advance wonderful forum members

#2 Shnupbups

  • Members
  • 596 posts
  • LocationThat place over there. Y'know. The one where I am.

Posted 04 March 2013 - 10:21 AM

Have you got the HTTP API as true in your config? That's the only explanation I can think of. It's off by default so you have to turn it on manually. Go into:
%appdata%/.minecraft/config/ComputerCraft.cfg
and there should be a line with:
# Enable the "http" API on Computers
    B:enableAPI_http=false
Set the 'false' to true and it should work.

#3 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 04 March 2013 - 01:51 PM

You could also add a check to ensure http is enabled like so:

if not http then
  return error("Http is not enabled!")
end

Pretty nice in some occasions.

Also, why are you making a pastebin program when CC already has one?

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 04 March 2013 - 02:03 PM

 SuicidalSTDz, on 04 March 2013 - 01:51 PM, said:

Also, why are you making a pastebin program when CC already has one?
Have you seen my "Program d" ... it was my first http program, its a good starting point ... just like door locks are the starting point of anything else ...

#5 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 04 March 2013 - 04:06 PM

 TheOriginalBIT, on 04 March 2013 - 02:03 PM, said:

 SuicidalSTDz, on 04 March 2013 - 01:51 PM, said:

Also, why are you making a pastebin program when CC already has one?
Have you seen my "Program d" ... it was my first http program, its a good starting point ... just like door locks are the starting point of anything else ...
Hmm, I guess you are right. ( Like the program btw :P )

Side Note:You seem to counter everything I have to say! Let the games begin :D (Even though challenging a Semi-Professional ComputerCrafter would call for the highest degree of sorcery)

#6 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 04 March 2013 - 05:20 PM

This error message would NOT be caused by HTTP being disabled. I'm on my phone so I can't see the code to tell you the real problem.

#7 SuicidalSTDz

    Permutator of Strings

  • Members
  • 1,308 posts
  • LocationPennsylvania

Posted 04 March 2013 - 05:35 PM

 immibis, on 04 March 2013 - 05:20 PM, said:

This error message would NOT be caused by HTTP being disabled. I'm on my phone so I can't see the code to tell you the real problem.
It seems to be erroring at line 6 which is where he defines the variable "response" The following is the exact same code as he posted, line for line.


local tArgs = { ... }
local sCode = tArgs[1]
local sFile = tArgs[2]
local sPath = shell.resolve( sFile )

local response = http.get("http://pastebin.com/raw.php?i=" ..sCode)

if response then
failed = false
local sResponse = response.readAll()
response.close()

local file = fs.open( sPath, "w" )
file.write( sResponse )
file.close()
print( "Downloaded as "..sFile )

else
print( "Failed." )
failed = true
fail()
end

#8 immibis

    Lua God

  • Members
  • 1,033 posts
  • LocationWellington, New Zealand

Posted 04 March 2013 - 08:04 PM

With http:
paste:21: attempt to call nil
Without http:
paste:6: attempt to index '?' (a nil value)

Conclusion: The code in the OP is different from the code he was actually trying to run.

#9 Dlcruz129

    What's a Lua?

  • Members
  • 1,423 posts

Posted 04 March 2013 - 08:06 PM

In-game: type "pastebin put [filename]"
As immibis said, you copied the code wrong.

#10 Engineer

  • Members
  • 1,378 posts
  • LocationThe Netherlands

Posted 05 March 2013 - 06:41 AM

do you have the function fail defined?

if not, then you should this above your code

function fail()
   -- What you want to do
end

But as I am typing this, dont you want to use error()? If this has been run directly from the shell, then you wont need the error() or fail() except if you want to do something else with fail()

I hope I've helped you,

Engineer

#11 Simon

  • Members
  • 58 posts
  • LocationSeattle

Posted 05 March 2013 - 07:03 AM

Hmm, it works now. Creepy.

Edit: Someone was messing with me on my server -_-





3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users