How can invoke an automatic "Y" in a script?

Posted on 2006-03-29
Last Modified: 2013-12-27
I have a small script:
mt rewind          
dd if=/dev/rmt/0n of=/dev/null  
/app_dsk/usr/dlc/bin/prorest apmdb /dev/rmt/0n

it is called by running the filename:
Problem is, that the program the script runs, always asks the question:
File Exists, Overwrite? (Y/N)
I have to manually press "Y" everytime.
How can I make the "Y" be entered automatically without me doing it?
Question by:rbend
    1 Comment
    LVL 10

    Accepted Solution

    Use a HERE document in Bourne shell:

    sh <<ENDHERE

    The ENDHERE part is simply something you choose - ENDHERE is what I've always used.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
    Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now