On Tue, Mar 08, 2005 at 08:16:16PM -0600, Steve Swantz wrote:
> I'm sure this will be easy for someone, but I'm not finding it now...
> 
> I have a perl program that  normally runs by cron, but occasionally
> manually. I want to handle the output differently depending on how it
> is run. Yes, I could add a flag to the arguments, but I seem to
> remember there being a more fundamental way to determine at runtime.
> Anyone know?

man 3 isatty

From perl, you can use the -t test. Depending what you need,
you can test STDIN or STDOUT.

---cut here---cut here---cut here---cut here
#!/usr/bin/perl -w

use strict;

if (-t STDOUT)
{
           print STDERR "interactive\n";
}
else
{
           print STDERR "non-interactive\n";
}

exit 0;
---cut here---cut here---cut here---cut here

Cheers,
florin

-- 

Don't question authority: they don't know either!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://shadowknight.real-time.com/pipermail/tclug-list/attachments/20050309/2c648c4a/attachment.pgp