[comp.sys.amiga.programmer] EXECUTE in C

zlnem@marlin.jcu.edu.au (N Milward) (01/12/91)

	I'm writing a C program that calls the 2 cli commands copy
and makedir.  I'm using the call 
				 status = Execute("copy ...",0,0);
			and	 status = Execute("makedir ...",0,0);

	I was wondering if there was a way to return errors from the
copy and makedir command.  Examples of this is if the directory 
already exists or if the disk is full.

	Any help would be much appreciated.

Ross Milward 	-   zlnem@marlin.jcu.edu.au

dave@cs.arizona.edu (Dave P. Schaumann) (01/13/91)

In article <1991Jan12.062506.19754@marlin.jcu.edu.au> zlnem@marlin.jcu.edu.au (N Milward) writes:
>
>	I'm writing a C program that calls the 2 cli commands copy
>and makedir.  I'm using the call 
>				 status = Execute("copy ...",0,0);
>			and	 status = Execute("makedir ...",0,0);
>
>	I was wondering if there was a way to return errors from the
>copy and makedir command.

Yes.  First, create an argv[] vector for the call, just like the one available
on entry to your program (assuming your running from a shell).

Then, do this:

  if( (Comm_Found = fexecv( argv[0], argv )) == 0 )
    Exit_Value = wait() ;

  fexecv() should be documented in your C manual.  I was unable to find any
documentation on wait(); I figured out how to do this by poking around in the
source to Matt Dillon's shell (thanks, Matt).

>	Any help would be much appreciated.

>Ross Milward 	-   zlnem@marlin.jcu.edu.au

Dave Schaumann      | We've all got a mission in life, though we get into ruts;
dave@cs.arizona.edu | some are the cogs on the wheels, others just plain nuts.
						-Daffy Duck.

dillon@overload.Berkeley.CA.US (Matthew Dillon) (01/14/91)

In article <652@caslon.cs.arizona.edu> dave@cs.arizona.edu (Dave P. Schaumann) writes:
>>
>>	I'm writing a C program that calls the 2 cli commands copy
>>and makedir.	I'm using the call
>>				 status = Execute("copy ...",0,0);
>>			and	 status = Execute("makedir ...",0,0);
>>
>>	I was wondering if there was a way to return errors from the
>>copy and makedir command.
>
>
>  fexecv() should be documented in your C manual.  I was unable to find any
>documentation on wait(); I figured out how to do this by poking around in the
>source to Matt Dillon's shell (thanks, Matt).

    oh no!  what a mess.

    First of all, the fexecv() stuff is a MANX hack.  I have spent
    literally hundreds of hours over the years trying to do an fexecv()
    equivalent *right*, and there is no way to do.

    This is the one case for getting 2.0 up and running the moment it is
    released.  Under 2.0, there are several new calls to load and run
    programs AND return the exit code, all nice and neat.  There are also
    new calls for handling the resident list and running resident programs.

    All in all a shell-writer's dream.

    If you can help it, avoid fexecv() and other compiler-specific routines
    (lattice's fork/exec as well) and wait for 2.0 .

>>	Any help would be much appreciated.
>
>>Ross Milward	-   zlnem@marlin.jcu.edu.au
>
>Dave Schaumann      | We've all got a mission in life, though we get into ruts;
>dave@cs.arizona.edu | some are the cogs on the wheels, others just plain nuts.
>						-Daffy Duck.

				    -Matt

--


    Matthew Dillon	    dillon@Overload.Berkeley.CA.US
    891 Regal Rd.	    uunet.uu.net!overload!dillon
    Berkeley, Ca. 94708
    USA

giguere@csg.uwaterloo.ca (Eric Giguere) (01/28/91)

In article <652@caslon.cs.arizona.edu> dave@cs.arizona.edu (Dave P. Schaumann) writes:
>  fexecv() should be documented in your C manual. 

Notice that fexecv() is a Manx C function, not a regular Amiga functions.
It does some weird stuff.

--
Eric Giguere                                       giguere@csg.UWaterloo.CA
           Quoth the raven: "Eat my shorts!" --- Poe & Groening