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

Shell.run PATH

Started by Gamezdude, 09 June 2014 - 11:16 PM
Gamezdude #1
Posted 10 June 2014 - 01:16 AM
In my 'startup' program it is supposed to run the program 'gpsstartup'
Both programs are on a floppy disk.

What do i type to get to the correct path? I know its something like the below.

Shell.run (cddisk"gpsstartup")
cptdeath58 #2
Posted 10 June 2014 - 01:26 AM
What you need to do is

shell.run("disk/gpsstartup") IF in disk.
you put things like disk/program or games/game because they are in a directory.
if it isn't in a directory then you do

shell.run("gpsstartup")
However, in your case they would be two
"disk" and "disk2"
if you had two disk drives then you need to figure out which is the correct drive.

If not then it is impossible to run a program on a disk in a disk drive to have it run a disk that isn't in a disk drive.

if it is one disk though just do

shell.run("gpsstartup")
Edited on 09 June 2014 - 11:27 PM
theoriginalbit #3
Posted 10 June 2014 - 01:32 AM
ctpdeath58's method is good, however if you want to code the program so it can find the correct path without knowing where the disk drive is, you can do it one of two ways.

The first way, using the path of the running program with shell.getRunningProgram (which is the startup), and finding the path with a combination of string.sub and fs.getName.
The second way, searching all drives around the computer (using peripheral.getNames and disk.isPresent), getting their mount path with disk.getMountPath and checking for the existence, of the mount path plus the file you're after, with fs.exists

The first way would probably be the easier one, and would work as long as the second program is with the startup program, however the second approach would be better if you have no idea where the second program is located.
cptdeath58 #4
Posted 10 June 2014 - 01:38 AM
That is also a good method as well.
Both ways are useful.
My Advice:
If you actually know where it is:
Mine or His.
if you don't:
His
Reason: First, My won't actually see where it is. it will just do it from what is specified. His can actually find it and execute it accordingly.