0

I've got a script which is configuring a software. When i run the script it asks for user input like the ports etc.

Is it possible to run the script and pass it strings from a file?

My file with inputs looks like:

8080
1100
password
password
y

I've tried to run this:

cat /installation/inputs | /etc/init.d/myprogram configure

EDIT: After editing the password the command worked. Maybe there was a wrong char in it which caused the error...

3
  • can you show us the output you're getting? Commented Dec 2, 2016 at 12:36
  • The output is an endless loop of the message "input3 cannot be null. Enter input3:" until i stop it with ^C. Commented Dec 2, 2016 at 12:43
  • I mean: copy/paste the real input of your program and the real values and edit your question for that. Commented Dec 2, 2016 at 12:46

1 Answer 1

1

The syntax below will run your script and pass each line of text from /installation/inputs as a single line of arguments.

/etc/init.d/myprogram configure `echo $(cat /installation/inputs)`

results in:

/etc/init.d/myprogram configure 8080 1100 password password y

Your script simply needs to check if there are command line args, assign each arg $1 - $5 to each necessary field and then bypass the input prompts.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.