Amiga.org
Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: arkanoid on March 04, 2007, 05:06:09 PM
-
Hi,
I'm trying to use DOS commands from within C code. Some work fine but others give me error. For example, system("dir") works but system("cpu") just produces the shell error: "sh: cpu: not found"
i thought maybe system() defaults to only the commands based in ROM (like Dir). So I used system("c:cpu") and still no luck. anyone know why?
-
You're using ixemul, so system() tries to launch the command with ksh (/bin/sh). Generally it should work, but ixemul is known to have some issues running some non-ixemul commands.
Try libnix, that'll work (gcc -noixemul).
-
Use System() (note capitalization) or SystemTags(): SystemTags("dir", TAG_DONE). This can be fine-tuned with a lot of tags, e.g. SYS_Input, SYS_Output, NP_Stack, etc. NP_Path can be used to give it search paths, see source code of Toolmanager for an example, otherwise it inherits.
-
In my code I do:
Execute("C:CPU >t:CPUoutput.txt",0,0);
For some reason I have never used System() (?)
-
thanks guys. all three solutions work. for this one though i'll probably go with -noixemul as I want to make it portable so i can just edit command #defines for different platforms.