Implementing Ctrl +C in a script as a part of automation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Implementing Ctrl +C in a script as a part of automation
# 1  
Old 06-02-2009
Implementing Ctrl +C in a script as a part of automation

Hi,

I am working on Solaris SPARC where we used start the BEA WebLogic Server for some project module. The server is started very simply by changing to its home directory and starting the script called ./startWebLogic.sh. Upto this no big deal.
Once the server get started and comes to runnning mode , the console output is remained. The Shell prompt "-bash-3.00$" does not return. Manually we type Ctrl+C and return to Bash prompt. But know it is the time time to automate the server start, i.e. A script will be doing all stuffs it will change to the home directory and start the server, but problem persists as it does not comes to bash promt after starting the server the script goes on executing it never comes to a halt as matter of fact we are not able to check its execution status. If we run that script with any CI tool say , Hudson it goes on building never stops. we have tried to make it as a back ground process. It did not work. I am not in favor of killing the process as it might affect server functionality. Can we implement the "Ctrl + C" like thing in command that after starting the server it automatically comes to a halt? Waiting for your suggestion. Thanks to all in advance.
# 2  
Old 06-02-2009

Does the script have an exit command?

You may need to source the script:

Code:
. ./startWebLogic.sh

# 3  
Old 06-02-2009
Quote:
Originally Posted by bhaskar_m
we have tried to make it as a back ground process. It did not work.
Unfortunately saying you've tried isn't the same as saying "look, this is what we've tried (posted code) and this is how it failed (posted error messages and whatnot)". Maybe not what you're looking for, but how about handing off the start command to the 'at' service instead?
# 4  
Old 06-02-2009
Hi Sir,

If I give an exit command in the script it does not executed at all because once the command called ./startWebLogic.sh is encountered the console locks. It not get rids of the command. The script looks like :

#! /bash/bin

do stuff.
ssh username@server "cd directory_of_server/bin; startWebLogic.sh &"

exit 0;

but the shell is not able to execute the exit it locks there only.
# 5  
Old 06-02-2009
Quote:
Originally Posted by bhaskar_m
If I give an exit command in the script it does not executed at all because once the command called ./startWebLogic.sh is encountered the console locks. It not get rids of the command. The script looks like :

When posting code, cut and paste it, do not retype it.

And please wrap it in [code] tags.
Quote:
Code:
#! /bash/bin

do stuff.
ssh username@server "cd directory_of_server/bin; startWebLogic.sh &"

exit 0;

but the shell is not able to execute the exit it locks there only.

It's not clear what you are trying to do. Perhaps you want:

Code:
ssh username@server "cd directory_of_server/bin; startWebLogic.sh" &

# 6  
Old 06-02-2009
Code:
ssh username@server "cd directory_of_server/bin;./startWebLogic.sh" &

exactly. That means it executes a command in remote server , changing directory and executing the startWebLogic.sh. Executing remote server is not a problem but how we can come out of this script after executing ./startWebLogic.sh ?
Thanks Sir, for providing the rules as I am a new comer here.
# 7  
Old 06-02-2009
Quote:
Originally Posted by bhaskar_m
Code:
ssh username@server "cd directory_of_server/bin;./startWebLogic.sh" &

exactly. That means it executes a command in remote server , changing directory and executing the startWebLogic.sh. Executing remote server is not a problem but how we can come out of this script after executing ./startWebLogic.sh ?

When the script finishes, you are out of it. What's the problem?

Perhaps you need to forget the ampersand (&), and not put it in the background?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with delaying script and implementing checks before completion

Hello everyone, I was wondering if any of you could help me with this. I am an absolute beginner and don't know how to program, but I can follow a tutorial and tweak code sometimes. My understanding of programing is limitted to what for and while loops do, and how if then else logic works. That... (2 Replies)
Discussion started by: tomeurp
2 Replies

2. Shell Programming and Scripting

Need help implementing a timout in my Shell Script for RHEL6

Hey Guys, My problem: I have a script that will be querying the database every minute to see if it gets a response, the response its querying for is "UP" in a table i made called dbup in the database. Now, I am trying to add the component to implement a timeout if the script does not get a... (2 Replies)
Discussion started by: mo_VERTICASQL
2 Replies

3. Shell Programming and Scripting

Automation of keyboard inputs..like Ctrl+d and Ctrl+a

Hi..! I'm stuck with my automation of starting a process and keeping it running even after the current ssh session has exited.. So i'm trying to use command 'screen'. which is doing exactly what i wanted, But the problem is automation of the same. i will have to press Ctrl+a and Ctrl+d for... (2 Replies)
Discussion started by: chandana hs
2 Replies

4. Shell Programming and Scripting

Help with implementing available memory status script

hi , i want write the script which automatically send an alert mail to my mail id when there is low memory available. things which i am able to implement -: i got the output of current memory status into one file . Than i break down the required coloumn and again send it in another file. My... (1 Reply)
Discussion started by: abhinav dixit
1 Replies

5. UNIX for Dummies Questions & Answers

Ctrl-V + Ctrl-J for newline character does not work inside vi editor

Hi friends, I am trying to add a newline char ('\n') between the query and the commit statement in the following shell script. #! /bin/sh echo "select * from tab; commit;" > data.sql I have tried typing in "Ctrl-V + Ctrl-J" combination which has inserted ^@ (NUL) character but the commit... (1 Reply)
Discussion started by: royalibrahim
1 Replies

6. Shell Programming and Scripting

How to handle CTRL+Z or CTRL+C in shells script?

Hi, while executing shell script, in the middle of the process, if we kill the shell script( ctrl+z or ctrl+c), script will be killed and the files which using for the script will be in the folder. How to handle those scenarios. Is there any possibilities, if user breaks the script, I need to... (3 Replies)
Discussion started by: ckchelladurai
3 Replies

7. Shell Programming and Scripting

ctrl-c in script

how to send ctrl-c signal in scripts ??? i am executing top command in .exp script top command gives cpu running activities on your machine eg # top top - 18:41:01 up 8:38, 5 users, load average: 0.03, 0.16, 0.16 Tasks: 172 total, 1 running, 170 sleeping, 0 stopped, 1 zombie... (3 Replies)
Discussion started by: alexzander18
3 Replies

8. Shell Programming and Scripting

Ctrl-C or Ctrl-Z causing exit the session

H! I have written script where it need to invoke the perl script in background, then write the pid in temp file then bring back the job to foreground. whenever the Ctrl-C or Ctrl-Z is pressed in the script has to exit and prompt should be dispalyed. but this script causing exit from shell session... (2 Replies)
Discussion started by: jramesh1
2 Replies

9. AIX

Disable ctrl-c,ctrl-d,ctrl-d in ksh script

I wrote a ksh script for Helpdesk. I need to know how to disable ctrl-c,ctrl-z,ctrl-d..... so that helpdesk would not be able to get to system prompt :confused: (6 Replies)
Discussion started by: wtofu
6 Replies

10. UNIX for Dummies Questions & Answers

Script ctrl+c

How do you make a script so the user can not press ctrl+c and break out of the script? Thanks, :) (1 Reply)
Discussion started by: newtounix
1 Replies
Login or Register to Ask a Question