home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / hp / 9297 < prev    next >
Encoding:
Internet Message Format  |  1992-08-14  |  2.1 KB

  1. Xref: sparky comp.sys.hp:9297 comp.unix.questions:10081 comp.unix.misc:3232
  2. Newsgroups: comp.sys.hp,comp.unix.questions,comp.unix.misc
  3. Path: sparky!uunet!utcsri!helios.physics.utoronto.ca!alchemy.chem.utoronto.ca!system
  4. From: system@alchemy.chem.utoronto.ca (System Admin (Mike Peterson))
  5. Subject: Re: Pls help: Misc questions
  6. Message-ID: <1992Aug14.180857.3791@alchemy.chem.utoronto.ca>
  7. Organization: University of Toronto Chemistry Department
  8. References: <1992Aug14.100417.23395@hp9000.csc.cuhk.hk>
  9. Date: Fri, 14 Aug 1992 18:08:57 GMT
  10. Lines: 38
  11.  
  12. In article <1992Aug14.100417.23395@hp9000.csc.cuhk.hk> a866700@hp9000.csc.cuhk.hk (Wong Siu To) writes:
  13. >
  14. >I also want to know how can I determine whether a process (say, "sh") is
  15. >a background job or an interactive one.  I submit jobs to a batch queue
  16. >(managed by NQS, a batch job managing system) which acts as if the user
  17. >logs in the system before executing the job.  I don't want several
  18. >commands in the .profile to be executed in this situation.  I hope that
  19. >the determination can be made somewhere in the process (probably a shell
  20. >script) itself, without the help of any external program.
  21.  
  22. You can try the 'tty -s' command, but that doesn't always work (it will
  23. always be true for every shell run under a login shell, even if you
  24. put it into the background and logout), but this method is probably OK
  25. for use in the .profile itself.
  26.  
  27. The method we are using in the .kshrc (which is run for every ksh)
  28. at the moment is:
  29.  
  30. if [ "$LEVEL" = "" ]; then
  31.    let "LEVEL = 0"
  32. fi
  33. if [ "$PS1" != "" -a "$LEVEL" = "0" ]; then
  34.    interactive=yes
  35. else
  36.    interactive=no
  37. fi
  38. let "LEVEL = $LEVEL + 1"
  39. export LEVEL
  40.  
  41. (do this before you set the prompt to something other than the null
  42. string). This method works by empirical observation, and could be
  43. broken at any time by HP. A reliable method to do this is ABSOLUTELY
  44. REQUIRED, though a better solution would be for HP to fix their
  45. brain-damaged 'stty' command to not cause the shell to abort/hang
  46. when not run in an interactive shell.
  47. -- 
  48. What are the chances that any computer system will ever "work" properly?
  49. ... and Slim just left town. -*- Mike Peterson, SysAdmin, U/Toronto Chemistry
  50.