Jump to content




[RESOLVED] Running a program off pastebin without creating any files WITHOUT using shell.run("pastebin etc.")


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

#1 Geforce Fan

  • Members
  • 846 posts
  • LocationMissouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension

Posted 27 April 2014 - 03:17 AM

Alright, before I say anything, I want to tell you I have tried looking at the default pastebin program but I could not make sense of it. I tried even replication its code but there was something I was missing.
Anyhow, basically I want to know how to implement paste bin's "run" feature into my program. How would I do this and could this be explained line-by-line?
Sorry for any mistakes, auto-correct on Mac OSX is annoying sometimes.




How to fix(for anyone who's searched here or found this looking for help)
First of all, you do
variable = http.get("http://pastebin.com/raw.phpi=PASTEIDHERE")
then you do
variable = loadstring(variable)
Then
setfenv(variable, getfenv())
then run variable in any way you want and you will have all your global functions and variables inside it but not local variables.

Edited by Hithere__, 27 April 2014 - 05:28 AM.


#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

Posted 27 April 2014 - 03:20 AM

I usually use something like this
shell.run("pastebin get code")
if I need something from pastebin. I prefer not to run from pastebin, as that will require you to connect every time.

#3 Geforce Fan

  • Members
  • 846 posts
  • LocationMissouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension

Posted 27 April 2014 - 04:18 AM

I do not need this file except for one time in my application. I cannot use shell.run("pastebin blah blah blah") in my program. I need to replicate pastebin run's functionality WITHOUT using shell.run("pastebin blah blah blah") or creating any kind of temporary file.

#4 HometownPotato

  • Members
  • 62 posts

Posted 27 April 2014 - 04:39 AM

http.get to return the text in 'http://pastebin.com/raw.php?i=IDHERE' and with that, I believe you could just run the loadstring function

#5 Geforce Fan

  • Members
  • 846 posts
  • LocationMissouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension

Posted 27 April 2014 - 04:46 AM

View PostHometownPotato, on 27 April 2014 - 04:39 AM, said:

http.get to return the text in 'http://pastebin.com/raw.php?i=IDHERE' and with that, I believe you could just run the loadstring function
Thank you! This really clears things up. With this, I might be able to release a public alpha of my my project tonight!

Edited by Hithere__, 27 April 2014 - 04:47 AM.


#6 Geforce Fan

  • Members
  • 846 posts
  • LocationMissouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension

Posted 27 April 2014 - 05:00 AM

Wait. How do I get things like functions to work inside of this? I've defined a global function but it will not work inside of this!
If there's no way to get my global variables/functions in there, could I pass them into it like a normal function?

Edited by Hithere__, 27 April 2014 - 05:08 AM.


#7 HometownPotato

  • Members
  • 62 posts

Posted 27 April 2014 - 05:04 AM

At the very bottom of your code (don't use local variables if you want to be able to access that variable) add:
return getfenv();

So you could assign the loadstring to a variable and you will now have a table of everything you need.

I forgot to add, if you are using an infinite loop then returning the environment is useless, since well you can't really do anything I guess.

Edited by HometownPotato, 27 April 2014 - 05:10 AM.


#8 Geforce Fan

  • Members
  • 846 posts
  • LocationMissouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension

Posted 27 April 2014 - 05:11 AM

View PostHometownPotato, on 27 April 2014 - 05:04 AM, said:

At the very bottom of your code (don't use local variables if you want to be able to access that variable) add:
return getfenv();

So you could assign the loadstring to a variable and you will now have a table of everything you need.

I forgot to add, if you are using an infinite loop then returning the environment is useless, since well you can't really do anything I guess.
wait, I add this before launching the string, or before doing load string?
I am inside a function inside an infinite loop inside a function.
AHA: I think I figured it out
setfenv(stringfunction, getfenv())
stringfunction
Of course it's not called stringfunction, but you get the point.

Edited by Hithere__, 27 April 2014 - 05:24 AM.


#9 HometownPotato

  • Members
  • 62 posts

Posted 27 April 2014 - 05:27 AM

I was thinking more of the lines like:

-pastebin code:
--etc code...
--return getfenv()

-CC code
--x = loadstring(pastebincrap)();
--x.functionInPB();

something like that

#10 Geforce Fan

  • Members
  • 846 posts
  • LocationMissouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension

Posted 27 April 2014 - 05:29 AM

what?
first of all nothing special can really be in the pastebin code-- not stuff like that. I'll link you to the finished program when I upload it shortly
Uploading it now. Will be full of bugs, graphical glitches, pointless buttons, weird APIs, useless functions, and inefficient code. I need to fix it up but I will release it for developers.

Edited by Hithere__, 27 April 2014 - 05:31 AM.


#11 Geforce Fan

  • Members
  • 846 posts
  • LocationMissouri, United States, America, Earth, Solar System, Milky Way, Universe 42B, Life Street, Multiverse, 4th Dimension

Posted 27 April 2014 - 05:46 AM

here's the link
http://www.computerc...eed-for-a-host/
will pm you it too





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users