From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f7344,a83f48e38df3b490 X-Google-Attributes: gidf7344,public X-Google-Thread: fc7fa,a83f48e38df3b490 X-Google-Attributes: gidfc7fa,public From: Brian Hibbert Subject: Re: Problem with C function 'system()'... Date: 1995/11/29 Message-ID: <49hq59$lh4@nntpd2.cxo.dec.com>#1/1 X-Deja-AN: 120492902 references: content-type: text/plain; charset=us-ascii organization: Digital Equipment Corporation mime-version: 1.0 newsgroups: comp.sys.vms,comp.os.vms x-mailer: Mozilla 1.2N (Windows; I; 16bit) "Carl J. Lambrecht" wrote: > >I am developing an application in C on a VAX 4100 running OpenVMS 6.1, >and I am having problems with using the system() function. At one point, >I use it to get a directory, and bring filenames into the program. That >works fine. However, I can not seem to get it to execute the following: > sysret=system(strcat("def sys$output ",redir_file)); >The C code compiles, links, executes fine, but the command does not >process during run time. Any ideas? Can I get around this by using >getenv() and putenv()? If so, how do I do this? Any answers are most >appreciated. Please email me at work : clambrecht@kinesisinc.com >Thanks in advance... > >-Carl Lambrecht >Kinesis Computing, Inc. I suspect the command is "working", the problem is it isn't doing what you want. The system() function spawns a subprocess, waits for it to complete, and returns the status from the call. What you are doing is changing SYS$OUTPUT for a temporary subprocess, I suspect you are trying to redirect the output of stdout. I don't know how to do this within C on a VAX (I have never tried it). I would probably use fprintf to specifically send the output redir_file. If this would require massive code duplication, I would probably move my output to a function that takes the output file as a parameter and either pass it stdout or the file handle for redir_file as needed. Brian Hibbert