home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / cplus / 18578 < prev    next >
Encoding:
Text File  |  1992-12-30  |  1.6 KB  |  61 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!ulowell!woods.ulowell.edu!tongb
  3. From: tongb@woods.ulowell.edu
  4. Subject: Piping and return code
  5. Message-ID: <1992Dec30.190028.1@woods.ulowell.edu>
  6. Lines: 50
  7. Sender: usenet@ulowell.ulowell.edu (News manager - ulowell)
  8. Organization: University of Lowell
  9. Date: Thu, 31 Dec 1992 00:00:28 GMT
  10.  
  11.  
  12. Hello,
  13.  
  14.       Does any one know how to put redirect output and get return code in C ?
  15.  
  16.       I am having a small problem to solve but searching through all
  17. the C books I cannot find any information mention how to make redirect
  18. and get a return code within a C program.
  19.       The problem is my C program will run an external DOS program
  20. which accept only input from standart input.  (The Novell LOGIN.EXE file).
  21. This can be done by using piping at DOS prompt.
  22. In turn, I have to be able to obtain the return code from the LOGIN
  23. program.  I had tried several approaches but none of them solved the
  24. problem.
  25.  
  26. 1.  Use the EXEC or SPAWN function
  27.     Using these functions I was not be able to pass the password to the
  28. program.  However I will be able to obtained the return code form
  29. LOGIN program.
  30.  
  31. 2.  Use the SYSTEM function
  32.  
  33.     E.g.  system("command.com /c echo password|login server/username");
  34.  
  35.     By using this function I was able to pass the password to the
  36. LOGIN program with piping but the program will return zero if the program
  37. executed sucessfully, the return code from the LOGIN.EXE was lost.
  38.  
  39.     Another requirement is this C program should not display any
  40. output to console.
  41.  
  42. Is there any solution ?  Please help!
  43.  
  44. Binh Tong   (tongb@woods.ulowell.edu).
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.