Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
PcStack

How do I use a variable as a pastebin code?

Question

Posted

I need help with using variables as codes for pastebin as I am making a browser program, what I am asking is how do I use a variable in the os.execute pastebin thing? please help I just switched over from CC

7 answers to this question

Recommended Posts

  • 0
Posted

You should use local variables to avoid future headache.

local component = require("component")
local modem = component.modem
local event = require("event")

print("Connent to which IP?")
local port = tonumber(io.read("*n")) -- # convert the string representation of a number to an actual number value
modem.open(port) -- # modem.open opens ports not IPs
modem.broadcast(port, "packets")
local message = select(5, event.pull("modem_message")) -- # get all event data after the 5th element/return value

os.execute("pastebin run " .. message)

 

  • 1
Posted

`os.execute` uses a string to run a program much like the shell does.

local paste_code = "ae64fgy"
local paste_opt = "f"
local command = table.concat({"pastebin get", paste_opt, paste_code}, " ")
os.execute(command)

 

  • 0
Posted

I also need help doing it with a wireless modem message for a browser program...

and pastebin run here is my code;

component = require("component")
modem = component.modem
event = require("event")
print("Connent to which IP?")
ip = io.read("*n")
modem.open(ip)
modem.broadcast(ip, "packets")
local _, _, from, port, _, message = event.pull("modem_message")
message = tostring(i)
local command = table.concat({"pastebin run message"})
os.execute(command)

 

  • 0
Posted
On 8/31/2018 at 7:30 PM, Molinko said:

You should use local variables to avoid future headache.


local component = require("component")
local modem = component.modem
local event = require("event")

print("Connent to which IP?")
local port = tonumber(io.read("*n")) -- # convert the string representation of a number to an actual number value
modem.open(port) -- # modem.open opens ports not IPs
modem.broadcast(port, "packets")
local message = select(5, event.pull("modem_message")) -- # get all event data after the 5th element/return value

os.execute("pastebin run " .. message)

Ik this but i will manipulate them to act like ips

thank you

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.