Amiga.org

Operating System Specific Discussions => Amiga OS => Amiga OS -- Development => Topic started by: arkanoid on March 04, 2007, 05:06:09 PM

Title: system() command
Post 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?
Title: Re: system() command
Post by: Piru on March 04, 2007, 05:10:44 PM
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).
Title: Re: system() command
Post by: Dietmar on March 04, 2007, 05:19:42 PM
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.
Title: Re: system() command
Post by: ChaosLord on March 04, 2007, 05:29:52 PM
In my code I do:

Execute("C:CPU >t:CPUoutput.txt",0,0);

For some reason I have never used System() (?)
Title: Re: system() command
Post by: arkanoid on March 04, 2007, 05:41:48 PM
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.