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

[LUA] fs.delete("startup")

Started by BlackRa1n, 24 March 2012 - 05:05 PM
BlackRa1n #1
Posted 24 March 2012 - 06:05 PM
I keep getting error saying Access Denied! :S
Casper7526 #2
Posted 24 March 2012 - 06:56 PM
Are you trying to delete the startup in rom?
BlackRa1n #3
Posted 24 March 2012 - 07:06 PM
Yeah :S
There must be something wrong with my Anti-Virus, because after it runs, you can't do anything to 'startup'. Can't edit it, can't delete it etc.
Here's the code:


if fs.exists('startupb') then
fs.delete("startup")
fs.copy("startupb","startup")
term.clear()
term.setCursorPos(1,1)
print("BlackRa1n Anti-Virus 1.0")
print("-----------------------------")
print("")
print("All Infected Files Removed From System!")
print("System will now reboot!")
disk.eject("right")
sleep(7)
os.reboot()
else end 
term.clear()
term.setCursorPos(1,1)
print("BlackRa1n Anti-Virus 1.0")
print("-----------------------------")
print("")
f = io.open("startup","w")
f:write("")
f:close()
print("All Infected Files Removed From System!")
print("System will now reboot!")
disk.eject("right")
sleep(7)
os.reboot()



It's really messy and not to well put together, mind telling me what's wrong with it?
kamnxt #4
Posted 24 March 2012 - 07:14 PM
I didn't get any errors…
BlackRa1n #5
Posted 24 March 2012 - 07:23 PM
I didn't get any errors…

If you run that program off of a floppy and name it 'startup' like I did you might. If you don't try typing: edit startup
And then type something.
kamnxt #6
Posted 24 March 2012 - 07:25 PM
Still no errors… Did you reboot the computer to run the program? Or did you cd to the disk and then run startup?
BlackRa1n #7
Posted 24 March 2012 - 07:27 PM
Still no errors… Did you reboot the computer to run the program? Or did you cd to the disk and then run startup?

I inserted the floppy and then rebooted.
kamnxt #8
Posted 24 March 2012 - 07:43 PM
Hm, did you have something else on the computer/disk?
ComputerCraftFan11 #9
Posted 24 March 2012 - 08:32 PM
Yeah :S
There must be something wrong with my Anti-Virus, because after it runs, you can't do anything to 'startup'. Can't edit it, can't delete it etc.
Here's the code:


if fs.exists('disk/startupb') then
    fs.delete("startup")
   fs.copy("disk/startupb","startup")
   term.clear()
   term.setCursorPos(1,1)
   print("BlackRa1n Anti-Virus 1.0")
   print("-----------------------------")
   print("")
   print("All Infected Files Removed From System!")
   print("System will now reboot!")
   disk.eject("right")
   sleep(7)
   os.reboot()
else end
term.clear()
term.setCursorPos(1,1)
print("BlackRa1n Anti-Virus 1.0")
print("-----------------------------")
print("")
f = io.open("startup","w")
f:write("")
f:close()
print("All Infected Files Removed From System!")
print("System will now reboot!")
disk.eject("right")
sleep(7)
os.reboot()



It's really messy and not to well put together, mind telling me what's wrong with it?

Try this, it will copy startupb from the disk into your pc
BlackRa1n #10
Posted 24 March 2012 - 09:08 PM
Yeah :S
There must be something wrong with my Anti-Virus, because after it runs, you can't do anything to 'startup'. Can't edit it, can't delete it etc.
Here's the code:


if fs.exists('disk/startupb') then
    fs.delete("startup")
   fs.copy("disk/startupb","startup")
   term.clear()
   term.setCursorPos(1,1)
   print("BlackRa1n Anti-Virus 1.0")
   print("-----------------------------")
   print("")
   print("All Infected Files Removed From System!")
   print("System will now reboot!")
   disk.eject("right")
   sleep(7)
   os.reboot()
else end
term.clear()
term.setCursorPos(1,1)
print("BlackRa1n Anti-Virus 1.0")
print("-----------------------------")
print("")
f = io.open("startup","w")
f:write("")
f:close()
print("All Infected Files Removed From System!")
print("System will now reboot!")
disk.eject("right")
sleep(7)
os.reboot()



It's really messy and not to well put together, mind telling me what's wrong with it?

Try this, it will copy startupb from the disk into your pc

'startupb' isn't in the cd. It's in the terminal and I need 'startup' to be deleted and then 'startupb' to be renamed or copied into 'startup'
ComputerCraftFan11 #11
Posted 24 March 2012 - 09:17 PM
Yeah :S
There must be something wrong with my Anti-Virus, because after it runs, you can't do anything to 'startup'. Can't edit it, can't delete it etc.
Here's the code:


if fs.exists('startupb') then
   fs.delete("startup")
   fs.copy("startupb","startup")
   term.clear()
   term.setCursorPos(1,1)
   print("BlackRa1n Anti-Virus 1.0")
   print("-----------------------------")
   print("")
   print("All Infected Files Removed From System!")
   print("System will now reboot!")
   disk.eject("right")
   sleep(7)
   os.reboot()
else
  term.clear()
  term.setCursorPos(1,1)
  print("BlackRa1n Anti-Virus 1.0")
  print("-----------------------------")
  print("")
  f = io.open("startup","w")
  f:write("")
  f:close()
  print("All Infected Files Removed From System!")
  print("System will now reboot!")
  disk.eject("right")
  sleep(7)
  os.reboot()
end



It's really messy and not to well put together, mind telling me what's wrong with it?

Try this, it will copy startupb from the disk into your pc

'startupb' isn't in the cd. It's in the terminal and I need 'startup' to be deleted and then 'startupb' to be renamed or copied into 'startup'

try this?
BlackRa1n #12
Posted 24 March 2012 - 09:41 PM
Yeah :S
There must be something wrong with my Anti-Virus, because after it runs, you can't do anything to 'startup'. Can't edit it, can't delete it etc.
Here's the code:


if fs.exists('startupb') then
   fs.delete("startup")
   fs.copy("startupb","startup")
   term.clear()
   term.setCursorPos(1,1)
   print("BlackRa1n Anti-Virus 1.0")
   print("-----------------------------")
   print("")
   print("All Infected Files Removed From System!")
   print("System will now reboot!")
   disk.eject("right")
   sleep(7)
   os.reboot()
else
  term.clear()
  term.setCursorPos(1,1)
  print("BlackRa1n Anti-Virus 1.0")
  print("-----------------------------")
  print("")
  f = io.open("startup","w")
  f:write("")
  f:close()
  print("All Infected Files Removed From System!")
  print("System will now reboot!")
  disk.eject("right")
  sleep(7)
  os.reboot()
end



It's really messy and not to well put together, mind telling me what's wrong with it?

Try this, it will copy startupb from the disk into your pc

'startupb' isn't in the cd. It's in the terminal and I need 'startup' to be deleted and then 'startupb' to be renamed or copied into 'startup'

try this?

Perfect! Now the only problem is is the f:delete on my other code (The Virus for the Anti-Virus). Mind taking a look at that for me? This is the program that creates the 'startupb' by creating a backup of 'startup', deleting 'startup' and then changing 'startup' so it shuts off computer.


term.clear() 
term.setCursorPos(1,1) 
if fs.exists('startup') then
fs.copy('startup','startupb')
fs.close()
print("Installing:") 
sleep(2) 
print("20% Complete!") 
sleep(1) 
print("30% Complete!") 
sleep(2) 
print("50% Complete!") 
sleep(3) 
print("80% Complete!") 
sleep(2) 
print("100% Complete!") 
fs.delete("startup")
fs.copy("/disk/virus","startup") 
textutils.slowPrint("Virus Install Successful!") 
sleep(2) 
textutils.slowPrint("Terminal will now reboot!") 
sleep(2) 
os.reboot()
else
term.clear()
term.setCursorPos(1,1)
print("Installing:") 
sleep(2) 
print("20% Complete!") 
sleep(1) 
print("30% Complete!") 
sleep(2) 
print("50% Complete!") 
sleep(3) 
print("80% Complete!") 
sleep(2) 
print("100% Complete!") 
fs.copy("/disk/virus","startup") 
textutils.slowPrint("Virus Install Successful!") 
sleep(2) 
textutils.slowPrint("Terminal will now reboot!") 
sleep(2) 
os.reboot()
end


ComputerCraftFan11 #13
Posted 24 March 2012 - 09:50 PM
not sure whats wrong with that…
kamnxt #14
Posted 24 March 2012 - 09:52 PM
There is no function called fs.close(). Remove it (line 5).