home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!ulowell!woods.ulowell.edu!tongb
- From: tongb@woods.ulowell.edu
- Subject: Piping and return code
- Message-ID: <1992Dec30.190028.1@woods.ulowell.edu>
- Lines: 50
- Sender: usenet@ulowell.ulowell.edu (News manager - ulowell)
- Organization: University of Lowell
- Date: Thu, 31 Dec 1992 00:00:28 GMT
-
-
- Hello,
-
- Does any one know how to put redirect output and get return code in C ?
-
- I am having a small problem to solve but searching through all
- the C books I cannot find any information mention how to make redirect
- and get a return code within a C program.
- The problem is my C program will run an external DOS program
- which accept only input from standart input. (The Novell LOGIN.EXE file).
- This can be done by using piping at DOS prompt.
- In turn, I have to be able to obtain the return code from the LOGIN
- program. I had tried several approaches but none of them solved the
- problem.
-
- 1. Use the EXEC or SPAWN function
- Using these functions I was not be able to pass the password to the
- program. However I will be able to obtained the return code form
- LOGIN program.
-
- 2. Use the SYSTEM function
-
- E.g. system("command.com /c echo password|login server/username");
-
- By using this function I was able to pass the password to the
- LOGIN program with piping but the program will return zero if the program
- executed sucessfully, the return code from the LOGIN.EXE was lost.
-
- Another requirement is this C program should not display any
- output to console.
-
- Is there any solution ? Please help!
-
- Binh Tong (tongb@woods.ulowell.edu).
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-