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

  1. Xref: sparky comp.sys.hp:9303 comp.unix.questions:10092 comp.unix.misc:3233
  2. Newsgroups: comp.sys.hp,comp.unix.questions,comp.unix.misc
  3. Path: sparky!uunet!gatech!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!pacbell.com!pbhya!dbsuthe
  4. From: dbsuthe@pbhya.PacBell.COM (Daniel B. Suthers)
  5. Subject: Re: Pls help: Misc questions
  6. Reply-To: dbsuthe@PacBell.COM (Daniel B. Suthers)
  7. Organization: Pacific * Bell, San Ramon, CA
  8. Date: Fri, 14 Aug 1992 21:27:35 GMT
  9. Message-ID: <1992Aug14.212735.1721@pbhya.PacBell.COM>
  10. References: <1992Aug14.100417.23395@hp9000.csc.cuhk.hk> <1992Aug14.180857.3791@alchemy.chem.utoronto.ca>
  11. Lines: 28
  12.  
  13. In article <1992Aug14.180857.3791@alchemy.chem.utoronto.ca> system@alchemy.chem.utoronto.ca (System Admin (Mike Peterson)) writes:
  14. >In article <1992Aug14.100417.23395@hp9000.csc.cuhk.hk> a866700@hp9000.csc.cuhk.hk (Wong Siu To) writes:
  15. >>
  16. >>I also want to know how can I determine whether a process (say, "sh") is
  17. >>a background job or an interactive one.  I submit jobs to a batch queue
  18.  
  19.  
  20. In SysV, it's 
  21.  
  22. if [ -t 0 ] ; then
  23.     echo "Yup, file descriptor zero is associated with a terminal." >&2
  24.     echo "It's interactive." >&2
  25. else
  26.     echo "Nope, this program's running in the background, from cron, etc." >&2
  27. fi
  28.  
  29.  
  30. This works well for any program that needs to prompt for information.  The idea
  31. is to check before prompting.
  32.  
  33.  
  34.  
  35. Daniel B. Suthers,  CCP.
  36. Technology Consultant, PCS & IN Development Lab,        Pac*Bell
  37. Voice: (510) 671-1325               UUCP:  pacbell!pbeos!dbsuthe
  38. ================================================================================
  39. =  Commit unexpected kindness and senseless acts of beauty.                    =
  40. ================================================================================
  41.