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