LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   generating the keyboard events in shell script (https://www.linuxquestions.org/questions/programming-9/generating-the-keyboard-events-in-shell-script-846004/)

anudeepshetty 11-23-2010 06:07 AM

generating the keyboard events in shell script
 
Hi everyone,
is it possible to generate keyboard event "Ctrl+c" from a shell script code.?

i have written a shell script to compile my application and copy it to the server home directory , inorder to run my application i need to start the server (by running a shell script). but before that i need to stop the the currently running instance of my server. to do that i have to generate a keyboard event (Ctrl+c which i press it manually). i want to automate the entire process by writing a shell script i am able to run the server just by adding ./run.sh in my shell script. but befoe that to stop my server can i generate a keyboard by using a shell script event(ctrL+C) to stop server.?

JohnGraham 11-23-2010 06:19 AM

Quote:

Originally Posted by anudeepshetty (Post 4168072)
is it possible to generate keyboard event "Ctrl+c" from a shell script code.?

Yes - ctrl+c is really just a way to send SIGINT, so use "kill -INT <pid>" or "killall -INT <program-name>".

anudeepshetty 11-24-2010 01:52 AM

Quote:

Originally Posted by JohnGraham (Post 4168089)
Yes - ctrl+c is really just a way to send SIGINT, so use "kill -INT <pid>" or "killall -INT <program-name>".

To do that i need to get the pid(processID) of the server , i use netstat -pl(manually) , how do i get the pid of the server instance running through the shell script.?

Thanks for the reply mate.


All times are GMT -5. The time now is 10:25 AM.