[comp.sys.ibm.pc] Spawning a DOS child process

njarhe@ee.ualberta.ca (The Bill Man) (06/14/91)

I am having trouble spawning an xcopy child process.  What happens is one of two
things : 1. the child process only recognizes the filename that I am trying to
copy, and copies it to the current directory  OR 2. the child process only
recognizes the disk drive and copies the contents of the disk to the current
directory.  I know there must be something I am doing wrong (but what it is I
haven't got the slightest idea).  If there is anyone out there that knows how
to spawn this type of process properly I would certainly like to know.

BTW I am using Borland C++ on a MegaCom XT turbo (not that it was important to
know but thought I would tell you none the less).

The following is a sample of what I was trying to accomplish.

#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <process.h>
#include <errno.h>

int main(void)
{
 cha  path_to_file[40],
      disk_drive[5],
      filename[15];

 int result;

 clrscr();
 printf("\n\n     Enter the name of the file to copy to disk : ");
 scanf("%s",filename);

 while (strlen(filename) > 12)
 {
  clrscr();
  printf("\n\n     Re-enter the name of the file to copy to disk : ");
  scanf("%s",filename);
 }

 sprintf(disk_drive," a: ");
 sprintf(path_to_file,"c:\\drill\\data\\%s",filename);

 result = execlp("xcopy.exe",path_to_file,disk_drive,NULL);

 if (result == -1)
 {
  perror("Error from execlp");
  exit(1);
 }

 return 0;
}

Please respond by E-mail.

Thanks in advance to those that respond.

Bill Njarheim

E-Mail : njarhe@ee.ualberta.ca

        //                                                            //
 $$$$$$$$  $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$    $$$$$$$$$
$$$   //   $                                              $   $$$   //
 $$$ //    $	THE BILL MAN				  $    $$$ //
   $$$     $						  $      $$$ 
   //$$$   $ YOU CAN PAY ME NOW, OR YOU CAN PAY ME LATER! $	 //$$$
  //  $$$  $ 						  $	//  $$$	
$$$$$$$$   $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$  $$$$$$$$$
//						              //