From: Wilfried Hennings Newsgroups: comp.os.msdos.djgpp Subject: winXP, gcc: calling a batch file via system() Date: Wed, 20 Nov 2002 16:02:14 +0100 Organization: Forschungszentrum Juelich GmbH Lines: 50 Message-ID: NNTP-Posting-Host: mut011 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: zam602.zam.kfa-juelich.de 1037804534 456009 134.94.127.14 (20 Nov 2002 15:02:14 GMT) X-Complaints-To: usenet AT fz-juelich DOT de NNTP-Posting-Date: Wed, 20 Nov 2002 15:02:14 +0000 (UTC) X-Newsreader: Forte Agent 1.92/32.572 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hello all, i am contributing to an open source project which should run under as many opsys as possible without needing much adaptation. It's a C program run from the command prompt, reading one ascii file and creating another one. It is developed under Linux and MacOS X and runs OK so far under IBM AIX, DEC OSF/1, and I am porting it to DOS by djgpp gcc. The DOS port runs OK under DOS and Win95/98, but has problems under WinNT, Win2000 and WinXP when an external batch file named "latex2png.bat" shall be called via the system() routine. (system() actually issues the command "latex2png" without the .bat extension so that this call is the same under unix for calling a shell script called "latex2png".) Yes, I've got the most recent djgpp 2.03 distribution: downloaded yesterday from simtel, and did a fresh install. After long trials, I could track down the problems as follows: There are really strange things going on between the implementation of the "system" subroutine in djgpp's gcc and the WinXP system: - WinXP has TWO command processors, the old DOS/Win95/98 compatible "command.com" and the new NT4/Win2000/WinXP version "cmd.exe". The console window first starts with cmd.exe but when system() issues the "latex2png" command, a new process is started, by default with command.com, and the batch file is processed by command.com. The default command processor invoked by system() can be overridden by setting the environment variable SHELL, e.g. SHELL=C:\WINDOWS\system32\cmd.exe. But that doesn't solve the following problems. - When "system" searches for the existence of latex2png, it abbreviates the name to "latex2pn". But when it actually invokes it, it looks for the full name. So the batch file is only interpreted if it is present twice, as "latex2pn.bat" and as "latex2png.bat". So I changed the name in the C source to "latex2pn". - Main problem: When the batch file is called standalone, everything works as it should. When it is called from the C program via system() I get the message "Not enough environment space". I could not find out how to increase this space: anything I do only increases the space for the console window mother process but not for the daughter process. Anyone having any clue? -- email me: change "nospam" to "w.hennings" Dipl.-Ing.(=M.Sc.Eng.) Wilfried Hennings c./o. Forschungszentrum (Research Center) Juelich GmbH, MUT All opinions mentioned are strictly my own, not my employer's.