Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Determining if a program was run from a command prompt.

by demerphq (Chancellor)
on Apr 12, 2006 at 16:11 UTC ( [id://542867]=note: print w/replies, xml ) Need Help??


in reply to Determining if a program was run from a command prompt.

UPDATE: Bah. This doesnt work. Never mind me. For some reason when you click on the script it gets executed from a console, so the -t tests says true. Wheras if i launch a script from my editor it shows false, so I assumed the same would be true when double-clicking. I shouldnt have assumed..... :-(

Sure, use the -t filetest operation to test if STDIN is connected to a TTY. Try the following script (you might have to change where the log gets written to.)

#!perl -l open my $log,">>C:/tmp/log.log" or die $!; my $term_type=-t STDIN ? "Terminal" : "Non Terminal"; print $log localtime(time)." $term_type"; print localtime(time)." $term_type";
---
$world=~s/war/peace/g

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://542867]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (2)
As of 2024-04-19 19:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found