LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-07-2014, 06:31 AM   #1
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,461
Blog Entries: 6

Rep: Reputation: 51
Need help with script..


Hello,

I have two commands as part of a script:


AdminServer:
Code:
cd /u01/oracle/wlsdomains/base_domain/bin/
./startWebLogic.sh
ManagedServer:
Code:
cd /u01/oracle/wlsdomains/base_domain/bin/
./startManagedWebLogic.sh managedserver_1
While the script is run the first startWebLogic gets run which ask for username and password. Once it reaches to the point when it says "The Weblogic Service IS RUNNING", I open the new terminal and run ./startManagedWeblogic.sh. It too asks for username and password.

How to include this all steps under a script?
 
Old 10-07-2014, 09:03 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Two way you can go here. Either use redirection or use the binary expect.

The firs one needs a file with the username and password. Each on one line. Now do

Quote:
./startWebLogic.sh < file_with_credentials
Could work. If not use expect. This a binary allows you to have it search the output of a programm for certain phrases and does action depending on it. This case would be an input. Expect can be hard to grasp at the beginning but the time invested sure is rewarding.
 
Old 10-07-2014, 11:44 AM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,366

Rep: Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915
Quote:
Originally Posted by your_shadow03 View Post
Hello,
I have two commands as part of a script: AdminServer:
Code:
cd /u01/oracle/wlsdomains/base_domain/bin/
./startWebLogic.sh
ManagedServer:
Code:
cd /u01/oracle/wlsdomains/base_domain/bin/
./startManagedWebLogic.sh managedserver_1
While the script is run the first startWebLogic gets run which ask for username and password. Once it reaches to the point when it says "The Weblogic Service IS RUNNING", I open the new terminal and run ./startManagedWeblogic.sh. It too asks for username and password.

How to include this all steps under a script?
Since you've been asking about scripting for five YEARS now, have you not been able to apply anything you've learned??

One of the many hits Google can lead you to:
http://bash.cyberciti.biz/security/e...-login-script/

...a sample expect script, showing how user names/passwords can be passed.
 
Old 10-07-2014, 01:26 PM   #4
your_shadow03
Senior Member
 
Registered: Jun 2008
Location: Germany
Distribution: Slackware
Posts: 1,461
Blog Entries: 6

Original Poster
Rep: Reputation: 51
zhjim, thanks for the response.
I wrote the following expect script:

Code:
#!/usr/bin/expect -f
spawn ./startWebLogic.sh
expect "Enter username to boot WebLogic server: "
send "weblogic\r"
expect "$ "
expect "Enter password to boot WebLogic server: "
send "Oracle9ias\r"
expect "$ "
send "exit\r"
Does it look Ok? I wonder if the last line send "exit\r" stops the process. The script should keep the Weblogic service running at the background.
Please suggest.

Similarly, I am going to add the expect script for ./startManagedWebLogicserver just below that..

Please suggest.
 
Old 10-07-2014, 01:35 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,366

Rep: Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915Reputation: 3915
Quote:
Originally Posted by your_shadow03 View Post
zhjim, thanks for the response. I wrote the following expect script:
Code:
#!/usr/bin/expect -f
spawn ./startWebLogic.sh
expect "Enter username to boot WebLogic server: "
send "weblogic\r"
expect "$ "
expect "Enter password to boot WebLogic server: "
send "Oracle9ias\r"
expect "$ "
send "exit\r"
Does it look Ok? I wonder if the last line send "exit\r" stops the process. The script should keep the Weblogic service running at the background.
Please suggest. Similarly, I am going to add the expect script for ./startManagedWebLogicserver just below that.. Please suggest.
Why don't you just run the script and find out??? But since all your script does is run ANOTHER script, it's fairly obvious that THAT script starts weblogic and keeps it running...since if it didn't, weblogic would die immediately after running the script.

Again, after five years of scripting, can't you apply ANY of the advice you've been given before, or see any of the expect tutorials?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script/Perl Script to remove the string until it finds special character '_' pooppp Programming 10 07-17-2012 10:36 AM
Shell script/Perl Script to remove the string until it finds special character '_' pooppp Programming 1 07-13-2012 02:03 AM
Shell script, Perl script, command or utility to convert Binary to text Perseus Programming 26 07-12-2012 07:00 AM
[SOLVED] Script question: create a shell script in kde to log in on a server with ssh c4719929 Linux - Newbie 1 01-31-2011 04:05 AM
How to get full path to script file inside script itself? And in case of sym links? maggus Linux - Newbie 3 05-28-2009 09:40 AM


All times are GMT -5. The time now is 01:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration