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

How to run a program on another computer

Started by computercraftrules89, 06 November 2012 - 02:11 PM
computercraftrules89 #1
Posted 06 November 2012 - 03:11 PM
Hi there its just me again

How would I run a program on another computer using computercraft.

I have a launch program already on one computer problem is that computer has to stay where it is right beside the launch terminal.

I was wondering say if you made the launch facility away from your home and you wanted to launch a missle remotely.

I know you could just use the remote thing that comes with the mod but for me that's to boring and simple.

I thought of using shell.run to do this but do not know of a way to get it to run that program remotely.
Kingdaro #2
Posted 06 November 2012 - 04:19 PM
For your specific purpose, you could just use rednet. Have your other computer wait for a rednet signal, and when it gets the signal, shell.run() the program you want.
computercraftrules89 #3
Posted 06 November 2012 - 04:45 PM
im trying that at the moment and the other computer wont receive the signal

sending computer
rednet.open("top")
rednet.send(id, "launch")
print("missle launched")
sleep(3)
rednet.close("top")

other computer
rednet.open("top")
id, msg = rednet.receive()
if msg == "launch" then
shell.run("launcher")
rednet.close("top")
end

the sending computer send the message but i never see the modem light on the other computer turn on and yeah the missle just sits there.
Luanub #4
Posted 06 November 2012 - 04:47 PM
What value do you have assigned to the var id for this command?

rednet.send(id, "launch")
PixelToast #5
Posted 06 November 2012 - 04:51 PM
if the modem dosent turn on then your not opening the right side
also you might want to loop the "other computer"s code:

rednet.open("top")
while true do
id, msg = rednet.receive()
if msg == "launch" then
shell.run("launcher")
rednet.close("top")
break
end
end
you also might want to add a password system :3

-snip- (what luanub said)
computercraftrules89 #6
Posted 06 November 2012 - 05:08 PM
What value do you have assigned to the var id for this command?

rednet.send(id, "launch")

what do you mean
Luanub #7
Posted 06 November 2012 - 05:27 PM
It should be the number of the computer you are sending to. So it should be something like..


local id = 1
rednet.send(id, "launch")

--or
rednet.send(1, "launch")
computercraftrules89 #8
Posted 06 November 2012 - 05:33 PM
Got it working had to load the program on the other computer that i called gotcommand

I will write down the code for both so other can do this

Sending computer

type edit (whatever) – replace whatever with whatever you called the program to send the missle launch command

rednet.open("top") – "top" = where the modem is placed
rednet.send(0, "launch") – 0 = the computer ID "launch" = the term used
print("missle launched") – prints missle launched
sleep(3) – Waits 3 seconds
rednet.close("top") –Closes rednet connection

press Ctrl enter
press Ctrl right enter

other computer

type edit (whatever) –whatever you want your command to receive the launch command to be called

rednet.open("top") – "top" = where the modem is placed
while true do – do everything below this line
id, msg = rednet.receive(10) keeps it listening for 10 seconds before it turns the modem off
if msg == "launch" then – If the message received is launch then it will do whatever is on the next line.
shell.run("whatever the launch program is called") – will run the program put the name of your launcher program here between the ""
rednet.close("top") – closes rednet connection
break
end
end

press Ctrl and then enter
press Ctrl right enter

on the same computer

type edit (whatever you call your launch program)

launcher = peripheral.wrap("right") –Tell the program the launcher is on the right of this computer computer has to be placed right next to launcher.

redstone.setOutput("right", true) –sends redstone pulse
sleep(3) – wait 3 seconds
redstone.setOutput("right", false) –guess this stops the redstone pulse
sleep(1) – wait 1 second
print("missle launched") – says missle launched
sleep(1) –wait 1 second
print("going back to main console") –says going back to main console
os.reboot() – reboots computer

press Ctrl enter
press Ctrl right enter

on the same computer

type edit startup
shell.run("whatever your program is called that gets the command") – runs program between " "

press Ctrl enter
press Ctrl right enter.

thats all

Thanks for the help guys program works and i will add in a password program

eventually i see if i can also get co ords from the launcher
and send that to the first computer aswell.