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

I end up with "No such program"

Started by DiamondOwner, 05 February 2013 - 01:57 PM
DiamondOwner #1
Posted 05 February 2013 - 02:57 PM
EDIT: Problem solved.
Some helpful info:
-This is downloaded to a computer from a floppy disk.
-The fs.mkDir should make a directory called "DiamondTNT-OS"
-"/DiamondTNT-OS" exists on the disk

os.pullEvent=os.pullEventRaw
function fs.remove()
end
function fs.copy()
end
function fs.mkDir()
end
print("Download is starting.")
if fs.isDir("DiamondTNT-OS")~=false then
   fs.mkDir("DiamondTNT-OS")
end
local programs= {"/DiamondTNT-OS/Login",
"/DiamondTNT-OS/Modifying",
"/DiamondTNT-OS/Password",
"/DiamondTNT-OS/Removing",
"/DiamondTNT-OS/Username",
"/DiamondTNT-OS/allow",
"/DiamondTNT-OS/startup",
"/DiamondTNT-OS/delete",
"/DiamondTNT-OS/deny",
"/DiamondTNT-OS/mainscreen",
"/DiamondTNT-OS/save1",
"/DiamondTNT-OS/save2",
"/DiamondTNT-OS/functions"
}
for i=1,13 do
   fs.remove(programs[i])
   fs.copy ("/disk"..programs[i],programs[i])
end
sleep(2)
print("Download is finished.")
sleep(2)
shell.run("/DiamondTNT-OS/startup")
shell.exit()
theoriginalbit #2
Posted 05 February 2013 - 03:12 PM
seems to me that the following program does not exist, is it being copied?

"/DiamondTNT-OS/startup"
DiamondOwner #3
Posted 05 February 2013 - 03:35 PM
yes it is

EDIT: It runs to the last print() command then it outputs "No such program". Can the shell.run() commands in "/DiamondTNT-OS/startup" produce the same error? The problem is that there is no indication of the line/program of the error.
theoriginalbit #4
Posted 05 February 2013 - 03:36 PM
can you run it from the terminal?
DiamondOwner #5
Posted 05 February 2013 - 03:40 PM
no, it doesn't seem to copy the files in the directory "DiamondTNT-OS" to the computer
theoriginalbit #6
Posted 05 February 2013 - 03:44 PM
So the files are on the disk as "disk/DiamondTNT-OS/<file name>"

On a side note, change your loop to this, then all you need to do is add new program strings.

for i=1,#programs do
fs.remove(programs[i])
fs.copy ("/disk"..programs[i],programs[i])
end
DiamondOwner #7
Posted 05 February 2013 - 03:48 PM
that's nice, instead of having to count how many parts of the function there is. that's correct. here's an image to help. also, thx for the quick replies. gtg @ 10:00.
theoriginalbit #8
Posted 05 February 2013 - 03:55 PM
can you upload a screenshot of "ls /disk" and "ls /"
DiamondOwner #9
Posted 05 February 2013 - 04:08 PM
Here is the snapshot. 1st ls shows the computer. 2nd ls shows the disk.
theoriginalbit #10
Posted 05 February 2013 - 04:11 PM
ok so its not actually copying the files from the disk to the computer, and thats why the startup file cannot be run, it can't find the program.

wow why didn't i see this earlier….


function fs.remove()
end
function fs.copy()
end
function fs.mkDir()
end

remove those
DiamondOwner #11
Posted 05 February 2013 - 04:16 PM
now i get "Download:4: attempt to call nil". can you fix this?
theoriginalbit #12
Posted 05 February 2013 - 04:17 PM
fs.makeDir i believe it is not fs.mkDir
DiamondOwner #13
Posted 05 February 2013 - 04:28 PM
I will try that tomorrow(My friend shut off the server.). If it works, thx so much and I will definitely include you in the OS credits. I have been stuck on this for like 10 minutes before deciding to ask a pro like you.
Dlcruz129 #14
Posted 05 February 2013 - 06:50 PM
Yeah, you overwrote some vital functions, which is a huge no-no.

(I've done stupid shit like this before, does anyone know if there's a way to revert this without starting over from scratch on a new computer?)
theoriginalbit #15
Posted 05 February 2013 - 06:52 PM
Yeah, you overwrote some vital functions, which is a huge no-no.
Not always, I overwrite base functions all the time, however they just add extra functionality and always revert once my program is over.

does anyone know if there's a way to revert this without starting over from scratch on a new computer?

reboot the computer and the globals will be loaded back in.
DiamondOwner #16
Posted 06 February 2013 - 09:00 AM
I changed "fs.mkDir" to "fs.makeDir" and received an error of "Download:21: attempt to call nil". this was the reason i tried to define the function fs.remove(). My new code:

os.pullEvent=os.pullEventRaw
print("Download is starting.")
if fs.isDir("DiamondTNT-OS")~=false then
   fs.makeDir("DiamondTNT-OS")
end
local programs= {"/DiamondTNT-OS/Login",
"/DiamondTNT-OS/Modifying",
"/DiamondTNT-OS/Password",
"/DiamondTNT-OS/Removing",
"/DiamondTNT-OS/Username",
"/DiamondTNT-OS/allow",
"/DiamondTNT-OS/startup",
"/DiamondTNT-OS/delete",
"/DiamondTNT-OS/deny",
"/DiamondTNT-OS/mainscreen",
"/DiamondTNT-OS/save1",
"/DiamondTNT-OS/save2",
"/DiamondTNT-OS/functions"
}
for i=1,#programs do
   fs.remove(programs[i])
   fs.copy("/disk"..programs[i],programs[i])
end
sleep(2)
print("Download is finished.")
sleep(2)
shell.run("/DiamondTNT-OS/startup")
shell.exit()
theoriginalbit #17
Posted 06 February 2013 - 01:47 PM
http://computercraft.info/wiki/Fs_(API)

its fs.delete not fs.remove
DiamondOwner #18
Posted 06 February 2013 - 03:05 PM
well now the program works. :)/>