Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

batch mode 1

Status
Not open for further replies.

art15t

MIS
Apr 8, 2002
77
GB
Hi People,

I want to incorporate an if statement in my code to check if the program is running in interactive or non-interactive mode, such that if it is running unattended I can feed it some data for the prompts or simply skip any prompts. I would prefer not to use a check for a TTY because I may at some stage in the future drop this program onto a pseudo terminal and this will then show an active TTY. Any ideas on the best way forward with this....I'm guessing that some of you are already using your own solution to this?

My definition for this I think would be a test to see if stdout is being directed to something other than /dev/tty. Would this be a good test??

ART
 
Is the tty command available to you? If so then just use the -s option and the exit code to determine standard input.

1 The standard input is not a terminal or pseudo-terminal,
0 The standard input is a terminal or pseudo-terminal.
 
Excellent Ygor that's just perfect!

Many Thanks!


ART
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top