Path: utzoo!attcan!uunet!mcvax!ukc!warwick!geoff From: geoff@cs.warwick.ac.uk (Geoff Rimmer) Newsgroups: comp.lang.c Subject: Re: execl()'ing batch files in DOS Message-ID: <1914@ubu.warwick.UUCP> Date: 23 May 89 17:31:44 GMT References: <302@ohs.UUCP> Sender: news@warwick.UUCP Organization: Computer Science, Warwick University, UK Lines: 51 In-reply-to: mday@ohs.UUCP's message of 16 May 89 19:34:02 GMT In article <302@ohs.UUCP> mday@ohs.UUCP (Matthew T. Day) writes: > Does anybody know if it's possible to execl() a batch file in DOS? I am > using MicroSoft C v5.1, and using MS-DOS v3.30. I have tried: > > execl("\command.com", "tryit.bat", NULL); > > and perror() tells me "No such file or directory." Any help or input would > be appreciated. The \ character when in a string constant has a special meaning. In particular, it is used to produce special characters sucg as \n \t \r \a \v etc. To get a real \, you should double it: "\\command.com". What you have written is actually undefined (according to ANSI C anyway). BTW in QuickC (and also MSC5.1), you are often allowed to use the UNIX-style '/' when calloing library functions such as "fopen". Note however that this will not work with the "system" function, and probably not with the exec and spawn family of functions. I was under the impression that to execute a batch file, you should do: command.com -c batch.bat In which case, you would require the following: execl("\\command.com", "\\command.com", "-c", "batch.bat", (char *)0); [a] [b] [c] [d] [e] [a] says where the program is to be found. [b] is argv[0] when command.com is run. [c] is the command flag. [d] is the batch file to run. [e] is a pointer to char NULL. Or maybe there's something about command.com that I don't know about? > +------------------------------------------------+-------------------------+ > | UUCP: ...!uunet!iconsys!ohs!mday (Matthew Day) | "He who laughs, lasts." | > | USMAIL: Orem H.S., 175 S 400 E, Orem, UT 84058 | | > +------------------------------------------------+-------------------------+ /---------------------------------------------------------------\ | GEOFF RIMMER | | email : geoff@uk.ac.warwick.cs | | address : Computer Science Dept, Warwick University, | | Coventry, England. | | PHONE : +44 203 692320 | | FAX : +44 865 726753 | \---------------------------------------------------------------/