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

Getting output from executed commands to mirror screens

Started by sploders101, 07 May 2013 - 01:50 PM
sploders101 #1
Posted 07 May 2013 - 03:50 PM
So I'm trying to get the output of commands from a turtle for an ssh program to mirror screens, and it always returns nil. Ask me for any further information and I will try my best to get it to you. Here is the code:

[EDIT] I have determined that it IS the server side but if you would like the client side let me know. Thank You! :)/>

Spoiler

rednet.open("right")
--function execute()
--return loadstring(msg)()
--end
while true do
id, msg = rednet.receive()
screen = loadstring(msg)()
stringscreen=tostring(screen)
print(stringscreen)
rednet.send(1608,stringscreen)
end
SuicidalSTDz #2
Posted 07 May 2013 - 04:49 PM
rednet.open("right")
function execute(msg)
 return loadstring(msg)
end
while true do
 local id, msg = rednet.receive()
 stringscreen = tostring(loadstring(msg))
 print(stringscreen)
 rednet.send(1608,stringscreen)
end
Try this?
Lyqyd #3
Posted 07 May 2013 - 05:02 PM
rednet.open("right")
function execute(msg)
 return loadstring(msg)
end
while true do
 local id, msg = rednet.receive()
 stringscreen = tostring(loadstring(msg))
 print(stringscreen)
 rednet.send(1608,stringscreen)
end
Try this?

That's even worse.

OP, if you're trying to get screen output, the best way to do it is terminal redirection. You could check out nsh if you're interested in a working example.
sploders101 #4
Posted 07 May 2013 - 06:02 PM
Yours looks nice, but I'd like to make my own. I thought of terminal redirection, but how would I do that over rednet?
PixelToast #5
Posted 07 May 2013 - 07:34 PM
google + the programs section
or just look through the programs section, your bound to find one

you cant do it yourself without knowing more about cc (its better to see how other peoples programs work)
Cranium #6
Posted 07 May 2013 - 07:37 PM
Don't bump topics. It is simply not allowed. If you want a response, wait a bit. We're not here 100% of the time, so please be patient.
Lyqyd #7
Posted 07 May 2013 - 08:00 PM
Yours looks nice, but I'd like to make my own. I thought of terminal redirection, but how would I do that over rednet?

That's why I suggested taking a look at nsh. It uses terminal redirection over rednet, so looking at how it does it may give you inspiration.
sploders101 #8
Posted 07 May 2013 - 08:03 PM
Don't bump topics. It is simply not allowed. If you want a response, wait a bit. We're not here 100% of the time, so please be patient.
Sorry I didn't know that I just saw it on lots of other forums.
Im new to forums (well, posting anyway)so I apologize.
sploders101 #9
Posted 07 May 2013 - 08:54 PM
So I take it there's no even remotely simple way to do this?
sploders101 #10
Posted 07 May 2013 - 09:12 PM
I found this: https://github.com/lyqyd/LyqydNet-Programs/blob/master/nshd
It looks like an api. How would I use it?
Lyqyd #11
Posted 08 May 2013 - 12:43 PM
Uh, that's not an API. It's a (probably broken) implementation of nsh for my LyqydNet system. If you're looking for something more like an API, you might find the RFC I posted about the Terminal Redirection over Rednet standard.
sploders101 #12
Posted 08 May 2013 - 01:01 PM
lol I just found that before I checked back here.
sploders101 #13
Posted 08 May 2013 - 01:19 PM
I found this: http://www.computercraft.info/forums2/index.php?/topic/6484-rfc-tror-terminal-redirection-over-rednet/
Could I run it in parallel with my remote control program to get full terminal redirection?
Lyqyd #14
Posted 08 May 2013 - 01:35 PM
You'd ideally want to integrate it into your remote control program. The controlling computer sends keystrokes/commands/whatever and the controlled computer sends back what's on the screen.
sploders101 #15
Posted 09 May 2013 - 11:55 AM
Ok I just found this as well:https://github.com/lyqyd/LyqydNet-Programs/tree/master/apis with some documentation. I think this has what I want so thank you and I'm sorry for any trouble I have caused as I am good at programming but maybe not your version of good as I am only 13.
sploders101 #16
Posted 09 May 2013 - 03:55 PM
I can't seem to get it to connect to anything. I'm sending connection requests to a turtle labeled "client" and it is listening for packets from "remote" but neither respond.
Lyqyd #17
Posted 09 May 2013 - 05:03 PM
You'd have to post the code you're using. Your posts indicate that you're using stuff that isn't what I suggested would be helpful, so I suspect you're on the wrong track somewhat.
sploders101 #18
Posted 10 May 2013 - 10:01 AM
The turtle is labeled: "client" and the computer is labeled: "remote"

turtle:

os.loadAPI("connection")
os.loadAPI("net")
shell.run("/modread")
shell.run("/netd")
net.netInit()
ncomputer = connection.listen("remote",24)

Computer:

os.loadAPI("connection")
os.loadAPI("net")
shell.run("/modread")
shell.run("/netd")
net.netInit()
nturtle = connection.open("client",24)
term.redirect(connection.text(nturtle))
Lyqyd #19
Posted 10 May 2013 - 12:43 PM
Looks like you're on the right track if you're wanting to do it through LyqydNet. I'll sit down and figure out what you'll need next when I get home from work.
sploders101 #20
Posted 10 May 2013 - 01:44 PM
Looks like you're on the right track if you're wanting to do it through LyqydNet. I'll sit down and figure out what you'll need next when I get home from work.

Thank you VERY much :D/>
sploders101 #21
Posted 12 May 2013 - 11:32 AM
lyqyd? I don't mean to be rude but I'm kind of waiting on an answer.
Lyqyd #22
Posted 12 May 2013 - 10:11 PM
It's been an unexpectedly busy weekend. I'll try to get to this tonight or tomorrow.
sploders101 #23
Posted 13 May 2013 - 09:02 AM
It's been an unexpectedly busy weekend. I'll try to get to this tonight or tomorrow.

Ok thank you very much.
sploders101 #24
Posted 16 May 2013 - 02:54 PM
I'm only bumping this 'cause it seems like this topic has been forgotten. If I cant even do it for that reason please let me know.