1

If Linux command has single prompt then we can handle it like following -

echo "password" | sudo -S ls

But startWebLogic.sh has two prompts, one for username and other for password to boot WebLogic server.

I tried with following

sh startWebLogic.sh << EOF
> user
> password
> EOF

but it end up with

<Aug 31, 2020 7:04:59 PM GMT> <Notice> <WebLogicServer> <BEA-000365> <Server state changed to FORCE_SHUTTING_DOWN.>
Stopping Derby server...
Derby server stopped.

Can you please suggest how I can pass two arguments of prompt in single command?

2 Answers 2

2

That is because the stdin gets closed with close()-function when the program cat exits. A nifty trick is to utilize cat + the parenthesises in bash, try this:

(echo -en "user\x0Apass\x0A" ; cat) | sh startWebLogic.sh

Update: what you want to do is to daemonize the whole thing, but at the same time don't stop taking input (ie. take input whenever you'd like/need it)? I got that right, yeah? If so I might be able to help you a bit more, but spoiling isn't always teaching, tho.

3
  • echo -en "user\npass\n" ...
    – Hannu
    Aug 31, 2020 at 22:23
  • Yes, that is more corrrect syntax-wise. But essentially, if treating the string as a "C-string", then it is exactly the same. :) Nov 3, 2020 at 3:07
  • b'59657320696e64656564207468652073616d652c2062757420616c736f2076657279206d7563682068617264657220746f206465636f64652c20696620796f7520636f6e74696e756520696e207468652073616d65207374796c652c20616e64206170706c79206974206f6e20616c6c206f6620796f757220746578742e' :-) - oh' btw, that is python syntax.
    – Hannu
    Nov 4, 2020 at 16:16
0

If your end goal is to start the weblogic servers and provide the user and password, weblogic has another feature where you create a file called boot.properties and in there you provide username and password for the user to be used to start webogic. The startWebLogic.sh script detects the existance of the file and it not asking the user to provide anything. FYI the file is encrypted after you create it and run the startWebLogic.sh script.

https://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/wls/12c/15-BootProp--4471/bootproperties.htm

1
  • 2
    Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
    – Community Bot
    Apr 23, 2022 at 21:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .