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

Automatically download Pastebin programs

Started by Barlender, 09 July 2015 - 06:19 AM
Barlender #1
Posted 09 July 2015 - 08:19 AM
Ok, so I am trying to create a program which uses pastebin links to download other programs onto the computer. I've seen this method done with other programs, I just never actually saw the command to do so.

The command which I attempted to use was:


if fs.exists("<program name>") ~= then
shell.run("pastebin get <pastebin code> <program name>")
end

The error I got when I ran this program was "bios:339: [string "startup"]:1: unexpected symbol". I assume the unexpected symbol refers to the "~", but I am not sure. Any help would be much appreciated.
Square789 #2
Posted 09 July 2015 - 03:24 PM
Very simple, you just compared the returned value with…nothing
The compiler expected the end of the statement with the brackets, but then you just put an operator there.
I'd use

if not fs.exists(filename) then
Also, don't use a string in the fs.exists()-function ("<program name>") but a variable.
Same with <pastebin code>, replace this with
shell.run("pastebin get "..pastecode.." "..filename)
Edited on 09 July 2015 - 01:27 PM
meigrafd #3
Posted 09 July 2015 - 03:49 PM
Have a look on this: https://github.com/seriallos/computercraft/blob/master/bootstrap.lua
KingofGamesYami #4
Posted 09 July 2015 - 04:28 PM

That really isn't relevant to the error in question. It's his file that's causing problems.
Barlender #5
Posted 10 July 2015 - 06:19 AM
Very simple, you just compared the returned value with…nothing
The compiler expected the end of the statement with the brackets, but then you just put an operator there.
I'd use

if not fs.exists(filename) then
Also, don't use a string in the fs.exists()-function ("<program name>") but a variable.
Same with <pastebin code>, replace this with
shell.run("pastebin get "..pastecode.." "..filename)

I tried your suggestion, and it worked! Also thank's for suggesting that I use a variable rather than a string, that was another issue I was having :P/> Thanks for the help