home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / os / msdos / programm / 9001 < prev    next >
Encoding:
Text File  |  1992-09-02  |  1.9 KB  |  41 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!cs.utexas.edu!milano!cactus.org!wixer!raistlin
  3. From: raistlin@wixer.cactus.org (Eli Boaz)
  4. Subject: Re: Environment variables when using system(...) command
  5. Message-ID: <1992Sep2.205255.23847@wixer.cactus.org>
  6. Organization: Real/Time Communications
  7. References: <1992Sep1.194508.10559@sactoh0.sac.ca.us>
  8. Date: Wed, 2 Sep 92 20:52:55 GMT
  9. Lines: 30
  10.  
  11. In article <1992Sep1.194508.10559@sactoh0.sac.ca.us> sap@sactoh0.sac.ca.us (Stephan A. Puga) writes:
  12. >If an environment variable is set before a program is run and the
  13. >program makes use of the system(...) command, how can I use the
  14. >environment variable in the system command?  I am writing a program
  15. >to be used on a network and there is a variable "username" set
  16. >before the program is run (this variable by the way is very
  17. >important to how WordPerfect 5.1 runs on the network), my program
  18. >invokes WP51 and tries to pass it the username variable, but it
  19. >doesn't work!  Is there no way I can get the new "local" command
  20. >shell to use the same "old" command shell's variables?
  21.  
  22. Well, first off, you need to get the environment variable into a program
  23. variable. (I do not know how to do this in C, but getenv() looks like
  24. it would be the correct choice under Turbo C/Borland C)
  25.  
  26. Then, concatonate the program variable (say "john") so that your
  27. system command will look like: system(syscmd);
  28. where syscmd="d:\wp51dir\wp.exe john ..." or something similar...
  29.  
  30. I have done something similar to this a while back while writing
  31. a login program and it's utilities for my pc in Turbo Pascal.
  32.  
  33. hope this helps,
  34.  
  35.  
  36. -- 
  37. Eli Boaz                      | Line noise provide by S.W. Bell Telephone!
  38. raistlin@wixer.cactus.org     | "Anyone not wearing 2 million sunblock is
  39. ...!cactus.org!wixer!raistlin |  going to have a REAL BAD DAY, get it?" -T2
  40. ----------------------------------------------------------------------------
  41.