Welcome, Guest. Please login or register.

Author Topic: system() command  (Read 2129 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline arkanoidTopic starter

  • Full Member
  • ***
  • Join Date: Feb 2007
  • Posts: 174
    • Show only replies by arkanoid
system() command
« 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?
Peg2/G4/MorphOS
Amiga A1200/060
 

Offline Piru

  • \' union select name,pwd--
  • Hero Member
  • *****
  • Join Date: Aug 2002
  • Posts: 6946
    • Show only replies by Piru
    • http://www.iki.fi/sintonen/
Re: system() command
« Reply #1 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).
 

Offline Dietmar

  • Full Member
  • ***
  • Join Date: Nov 2002
  • Posts: 220
    • Show only replies by Dietmar
    • http://devplex.awardspace.biz
Re: system() command
« Reply #2 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.
 

Offline ChaosLord

  • Hero Member
  • *****
  • Join Date: Nov 2003
  • Posts: 2608
    • Show only replies by ChaosLord
    • http://totalchaoseng.dbv.pl/news.php
Re: system() command
« Reply #3 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() (?)
Wanna try a wonderfull strategy game with lots of handdrawn anims,
Magic Spells and Monsters, Incredible playability and lastability,
English speech, etc. Total Chaos AGA
 

Offline arkanoidTopic starter

  • Full Member
  • ***
  • Join Date: Feb 2007
  • Posts: 174
    • Show only replies by arkanoid
Re: system() command
« Reply #4 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.
Peg2/G4/MorphOS
Amiga A1200/060