LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-23-2010, 06:07 AM   #1
anudeepshetty
LQ Newbie
 
Registered: Nov 2010
Posts: 2

Rep: Reputation: 0
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.?
 
Old 11-23-2010, 06:19 AM   #2
JohnGraham
Member
 
Registered: Oct 2009
Posts: 467

Rep: Reputation: 139Reputation: 139
Quote:
Originally Posted by anudeepshetty View Post
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>".
 
1 members found this post helpful.
Old 11-24-2010, 01:52 AM   #3
anudeepshetty
LQ Newbie
 
Registered: Nov 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by JohnGraham View Post
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.

Last edited by anudeepshetty; 11-24-2010 at 01:58 AM.
 
  


Reply



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
write a shell script to enter ur name through keyboard and print it yusufsiddiqui Linux - Newbie 2 10-11-2009 06:46 AM
Keyboard events interrupting mouse events. miner49er Linux - Hardware 3 11-04-2008 04:16 AM
mousewheel generating two events instead of one zefo Linux - General 1 07-18-2007 02:09 AM
Generating 'fake' keyboard keypresses duncanbojangles Programming 6 03-25-2006 02:39 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:20 AM.

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
Open Source Consulting | Domain Registration