Jump to content




[Solved] Os.run with _G table


6 replies to this topic

#1 Ajt86

  • Members
  • 42 posts

Posted 13 January 2016 - 08:56 PM

When calling os.run with the global table, I get a "loop in gettable" error.

How would I use it with the global table?

Edited by Ajt86, 14 January 2016 - 09:03 PM.


#2 Micheal Pearce

  • Members
  • 87 posts
  • LocationUSA

Posted 13 January 2016 - 09:01 PM

are you trying to pass _G through os.run so the program can use it?

#3 Bomb Bloke

    Hobbyist Coder

  • Moderators
  • 7,099 posts
  • LocationTasmania (AU)

Posted 14 January 2016 - 12:29 AM

... if so, don't. They have access to it anyway. Either make a new environment table, or, if you want to run the script using the same environment as the shell you're using, use shell.run() instead.

#4 Ajt86

  • Members
  • 42 posts

Posted 14 January 2016 - 04:15 PM

View PostBomb Bloke, on 14 January 2016 - 12:29 AM, said:

They have access to it anyway.

I've tried passing it an empty table, but that doesn't work, they don't have access to global environment variables previously set in the same program (and that's also a relief for sandboxing).

Edited by Ajt86, 14 January 2016 - 04:16 PM.


#5 MKlegoman357

  • Members
  • 1,170 posts
  • LocationKaunas, Lithuania

Posted 14 January 2016 - 06:11 PM

Why are you using os.run instead if shell.run? If you can, you should be using shell.run, as it runs the programs in a proper environment. The global variables of programs are stored not in the _G table but rather in the shell's program environment, so to get that the best way would be to use shell.run.

#6 Lupus590

  • Members
  • 2,029 posts
  • LocationUK

Posted 14 January 2016 - 06:23 PM

http://www.computerc...lrun-and-osrun/

this AAP may help

#7 Ajt86

  • Members
  • 42 posts

Posted 14 January 2016 - 09:03 PM

View PostLupus590, on 14 January 2016 - 06:23 PM, said:


Thank you Lupus but I already know what each one does. I've solved the problem by assigning all the global variables I want to pass down to a key in a table, which I then pass in to os.run/





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users