0

I want to send input from one script to another through shell scripts

when I stop this script it display the message do u want to continue

$MAIN_SCRIPT_PATH/first.sh stop 

I am stopping the script using another script.I need to send yes to this script first.sh. How I will do this?

when stopping the first.sh it ask for user input. do you want to continue? I should send yes....

5

2 Answers 2

1

You could try writing to stdin of the script and see if that works. For example,

echo yes | $MAIN_SCRIPT_PATH/first.sh stop 

Otherwise, there are programs like expect which allow you to wait for certain prompts before emulating user input.

Also, that's a poorly written script if it is asking for confirmation to stop without giving any additional options. See if first.sh --help displays any additional info around skipping the user input. There's typically a -y / -q / -s option to scripts which silence user input.

    0

    On linux, the coreutils package ships even the yes command. So you would run:

    yes | $MAIN_SCRIPT_PATH/first.sh stop 
    0

      You must log in to answer this question.

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.