Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have installed Ubuntu on a VMWare virtual machine.

When I got to installing a VMWare tools, I have stumbled upon a simple question:

If I execute a script (perl script in VMWare tools case), is there a way for me to tell the execution beforehand, that if it prompts me for an input, given that it has a default value, it just uses it, not waiting for me to press Enter?

share|improve this question
Could you clarify what you mean, and what your end goal is? By 'default' do you mean enter the same string for every input, or separately for each? – Chris Down Sep 20 '11 at 17:12
up vote 6 down vote accepted

yes is designed for this purpose; it outputs the same string to stdout continuously, so you can pipe it into another script and it will keep answering the same for every prompt. It defaults to y so it can say "yes" to the prompts, but if you just want it to send a newline each time you can pass it the empty string as an argument:

$ yes '' | vmware-script
share|improve this answer
Thank you. So even if I want to be sending newline of each prompt, I still use $ yes '' as shown in your example? – Maxim V. Pavlov Sep 20 '11 at 17:47
@Maxim It outputs whatever string you give it, followed by a newline, so if you give it an empty string it will output just the newline. I used two single-quotes; yes "" will also work – Michael Mrozek Sep 20 '11 at 17:50

Either patch the source to have a default, or use a here document or here string to send your input to the script's stdin:

./script << EOF
answer 1
answer 2
answer N

Certain programs may not accept this (usually ones handling authentication which may disable this for security purposes). In this case, look into using something like expect.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.