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

Wierd problem with shell.run

Started by Creeper9207, 06 August 2015 - 05:10 PM
Creeper9207 #1
Posted 06 August 2015 - 07:10 PM
this program seems to work fine, but shell.run won't work, any idea why?

sorry for the crappy formatting

function process(dir)
local a = dir:sub(1,1)
if a == "/" then
  fPath="/emu"..dir
else
  fPath="/emu/"..dir
end
return fPath
end
ofsopen = fs.open
pocket = true
ofsexists = fs.exists
ofsisDir = fs.isDir
ofsisReadOnly = fs.isReadOnly
ofsgetName = fs.getName
ofsgetDrive = fs.getDrive
ofsgetSize = fs.getSize
ofsgetFreeSpace = fs.getFreeSpace
ofsmakeDir = fs.makeDir
ofsmove = fs.move
ofscopy = fs.copy
ofsdelete = fs.delete
ofsopen = fs.open
ofsgetDir = fs.getDir
fs.open=function(fn,fm)
b = process(fn)
return ofsopen(b,fm)
end
shell.run("n")

edit: it says "file not found"
and yes, the file is there, and is in the base directory, and ive also tried putting it in the only other dir on the computer
Edited on 06 August 2015 - 05:19 PM
KingofGamesYami #2
Posted 06 August 2015 - 08:07 PM
Try adding this before the line

return ofsopen(b,fm)


if not fs.exists( b ) then
  error( b .. " was not found!" )
end

That'll tell you want you're trying to run..
Bomb Bloke #3
Posted 06 August 2015 - 11:44 PM
"File not found" or "No such program"?

You're remembering to reboot the computer every time you run your code, right? Every time you execute it, a new fs.open will be defined - first you'll have one that points to /emu/*, then one that points to /emu/emu/*, then one that points to /emu/emu/emu/*…

shell.run() itself performs an existence check on the file before it attempts to open it. It'll never get around to opening "/emu/n" if it can't first confirm "n" exists - you'd need to add your path manipulation code to fs.exists() for that. Probably other fs API functions, too.
Creeper9207 #4
Posted 08 August 2015 - 01:56 AM
yes i did reboot every time

ok yes, i am trying to run /emu/n, new problem, now it says "No such program"

But, the program is running
Bomb Bloke #5
Posted 08 August 2015 - 07:04 AM
Ok, so have you performed the fs.exists() override I mentioned yet? It's not optional.
Creeper9207 #6
Posted 08 August 2015 - 05:04 PM
oh, ok, thank you ill try this asap, just on the side, does anyone know a desktop emulator for windows 10?
valithor #7
Posted 08 August 2015 - 05:15 PM
oh, ok, thank you ill try this asap, just on the side, does anyone know a desktop emulator for windows 10?

http://www.computercraft.info/forums2/index.php?/topic/18789-ccemuredux-development/

Might work for what you are wanting.