Re: [SLUG] bash - moving up a notch

From: Kwan Lowe (kwan@digitalhermit.com)
Date: Fri Jan 06 2006 - 12:07:23 EST


> On Wed, 5 Oct 2005, Mike Branda wrote:
>
>> anybody know how to in essence "auto fill" a read in sh/bash??
>>
>> for example:
>>
>> foo.sh runs another program inside itself that asks a question and then
>> waits for a return off of a read. Based on a test of the question
>> (redirected from stdout?) a predefined variable is entered as the answer
>> and then returned somehow to the inside program.

There are a couple ways to do this. E.g.:

: ${LOG_PATH:="/var/log"}

# Addresses to send the final logs
: ${LOG_RECIPIENTS:="admin@digitalhermit.com "}

# Host with NFS exports
: ${REMOTE_HOST:="helios.digitalhermit.com"}

These lines will set a default value if the environment variable is not set. You
could read these variables then run the above code after. If the user inputs nothing
(.e.g, presses ENTER) then the default values will get set.

>> Is this possible? I have a config program that has to be run multiple
>> times (different machines) with the same answers.

-- 
* The Digital Hermit   http://www.digitalhermit.com
* Unix and Linux Solutions   kwan@digitalhermit.com
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS).  Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 16:09:18 EDT