When I run add-user script(/opt/wildfly/bin/add-user.sh) , it asks for various inputs

1> a. management user, b. application user
2> Username :
3> Password :
4> Are you sure you want to user the password entered yes/no?
5> Re-enter password : What groups do you want this user to belong to? (Please enter a comma separated list, or leave blank for none)[  ]:

My question is how do I write a shell script which will add a management user named 'admin', password as "admin1" and no groups, without a manual intervention?

  • I don't know about add-user.sh and wildfly. But you can use expect script language: expect.sourceforge.net. It works like 'wait-input' scenario and easy to use. – Yurij Goncharuk Mar 25 '18 at 20:50
  • 1
    If the script reads from stdin then you can simply use a pipeline: echo foo | add-user.sh. If it reads from its controlling terminal then you need something like expect or socat. – Hauke Laging Mar 25 '18 at 20:53
  • @HaukeLaging thanks for socat. I don't know about this utility. I will remember it. – Yurij Goncharuk Mar 25 '18 at 20:57
  • Note, if you choose expect, you can look at autoexpect which will generate the script for you if you go through the interaction once with it. You may need to tweak the script, so do still read up on the expect language from its man page. – meuh Mar 26 '18 at 8:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.