How to handle multiple warning message when we are running any linux application through bash script?

I am running a application through bash script. when we execute the script, application will start and two different warning message ask for [y/n]? for first warning i want to give "Y" and for another "N" but it should take from script only. I don't want to use any user intervention

for single warning we can handle through echo 'y' | command. but how to use for multiple warning handling? Please help

Answers


I not sure what you want, but almost for every Linux bash command there are a lot of options. For example if you want to remove a file, Linux will ask you if you really want to do that (if you use this command: #rm -i file2.txt, you will get this prompt rm: remove regular empty file `file2.txt'? y).

To ignore that prompt you can use following option for rm command -f: #rm -f file2.txt where -f means -force

So try to do #man to see if there is an option to avoid prompt.


Pass arguments (Y and N or anything else) to the script call like this...

./script.bash Y N

These can then be accessed in the script (script.bash) with the $1 and $2 variable names. Also you can use $3 $4 .. $N etc.

For example...Script contents

#!/bin/bash

echo $1
echo $2

will return

Y
N

Need Your Help

ContentControl is not visible when application starts via UI Automation test, but its visible when application starts by user

c# wpf xaml devexpress ui-automation

We are using the prism and WPF to build application. Recently we started using UI Automation (UIA) to test our app. But some strange behavior occurred when we run UIA test. Here's simplified shell:...

how to solve 'this' problems with node libraries like async and request

node.js this libraries

I've written a node script that gets some data by requesting REST API data (using the library request). It consists of a couple of functions like so: