Jeff Abrahamson on Wed, 8 Jan 2003 13:00:50 -0500


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Detecting Background

  • From: Jeff Abrahamson <jeff@purple.com>
  • To: phl@lists.pm.org
  • Subject: Re: Detecting Background
  • Date: Wed, 8 Jan 2003 12:52:56 -0500
  • >received: from asterix.purple.com (asterix [192.168.0.6]) by diderot.purple.com (8.12.3/8.12.3/Debian -4) with ESMTP id h08HqukX014537 for <phl@lists.pm.org>; Wed, 8 Jan 2003 12:52:56 -0500
  • Mail-followup-to: phl@lists.pm.org
  • Reply-to: phl@lists.pm.org
  • Sender: owner-phl@lists.pm.org
  • User-agent: Mutt/1.4i

On Wed, Jan 08, 2003 at 12:46:34PM -0500, Urb LeJeune wrote:
> 	Is it possible for a Perl script to detect if it's running as a
> background task? If running from the command line I want to
> display progress messages, if running as a cron job I don't want
> to print. I could pass a parameter when running as a cron job but
> wanted to see if there was an easier way.

isatty(STDOUT)

Your spelling may vary, answer provided in the hopes that a fast
approximate answer is worth something.

This will also detect writing to a pipe.

What does background mean on unix? That's rhetorical.

-- 
 Jeff

 Jeff Abrahamson  <http://www.purple.com/jeff/>
 GPG fingerprint: 1A1A BA95 D082 A558 A276  63C6 16BF 8C4C 0D1D AE4B

-
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**