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

Execute remote program via wires

Started by Wice, 12 April 2014 - 10:06 PM
Wice #1
Posted 13 April 2014 - 12:06 AM
Hello, I'm using ComputerCraft 1.61 on Minecraft 1.64 and I've got two computers, conencted via modem and wires (so no wireless) and I'm trying to make a program on computer_1 execute on computer_2 but I can't get it to work and I've been searching for quite some time but I haven't found a work solution. Is this possible and if so, how?
CometWolf #2
Posted 13 April 2014 - 10:40 AM
It's quite easy, set comp one up to shell.run whatever message it receives, then send it a message.

shell.run(rednet.receive())
Wice #3
Posted 13 April 2014 - 10:51 AM
It's quite easy, set comp one up to shell.run whatever message it receives, then send it a message.

shell.run(rednet.receive())

Thanks for the answer but I don't really understand what you mean, could you give en example?
CometWolf #4
Posted 13 April 2014 - 11:08 AM
The code is posted literally is all you need, just send it a message while that is running and it will try to start the program you sent in the message.
Bomb Bloke #5
Posted 13 April 2014 - 11:30 AM
Well, not exactly. He wants to run a program stored on one computer, via a different computer. The line you're suggesting relies on the script being stored on the system that is to execute it.

Wice, what've you got so far?

Edit: It strikes me that this is the sort of thing nsh is for.
Edited on 13 April 2014 - 09:34 AM
CometWolf #6
Posted 13 April 2014 - 11:35 AM
Ah right, my apologies :P/>
That should be pretty simple as well. Just open the file with fs.open and read the contents in with readAll, then send the content over rednet to a computer setup to use loadstring on whatever it receives.
Lyqyd #7
Posted 13 April 2014 - 12:25 PM
Edit: It strikes me that this is the sort of thing nsh is for.

Well, kind of. You could think of nsh as CometWolf's first suggestion on crack–it starts a shell session that is being executed on one computer and displayed on another. With the optional put program for nsh, OP could transfer the code across to the other computer to execute, but it still has to be copied first. nsh will probably work just fine for what OP wants to do. If nsh won't cover OP's use case and he actually really does want to have code executed on a computer but stored on a different computer, CometWolf's second suggestion would work.

More importantly, Wice, could you expand on what exactly you are trying to do? Knowing what you plan to do with the answer to your question will help us provide the best answer possible.