LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 04-06-2014, 10:48 AM   #1
ramukumar555
LQ Newbie
 
Registered: Apr 2014
Posts: 4

Rep: Reputation: Disabled
Question How to capture ^x,^y via bash script


Hi
I am new to this forum.
Any please help me to capture ctrl x and ctrl y via a bash script.

and please tell me how to clear the prompt via bash script

BR
Ramukumar M
 
Old 04-06-2014, 12:09 PM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,247

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
It might help if you provided some back ground on what you actually want to do, as those combinations are not generally familiar?

Also, what have you tried?
 
Old 04-06-2014, 12:13 PM   #3
ramukumar555
LQ Newbie
 
Registered: Apr 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
I am doing a mini project following are the requirement
1. end user will connect to the system via ssh
2. all the key board inputs should be captured and based on "enter" it should send to another script as argument
3. control + y, control + x should be ignored

Please provide me a good solution
 
Old 04-06-2014, 12:17 PM   #4
ramukumar555
LQ Newbie
 
Registered: Apr 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
I did the following
I edited the .bashrc file as follow

Code:
# Source global definitions
if [ -f /etc/bashrc ]; then
	printf "<  "
fi
while read commnad
do
   myscript $command
done
but i need to do special handling for control x and control y
if control x is pressed i need to say "control x is pressed:" and come back to prompt
same for control y

Please do the needful
 
Old 04-06-2014, 02:06 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 17,925

Rep: Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690Reputation: 3690
Quote:
Originally Posted by ramukumar555 View Post
I am doing a mini project following are the requirement
1. end user will connect to the system via ssh
2. all the key board inputs should be captured and based on "enter" it should send to another script as argument
3. control + y, control + x should be ignored

Please provide me a good solution
Don't post the same question multiple times:
http://www.linuxquestions.org/questi...90#post5147690

...and please don't ask us to do your homework for you. Show us what effort YOU have put forth first.
 
Old 04-06-2014, 02:08 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 2,959

Rep: Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268Reputation: 1268
The first thing I would do is get clarification of just what is meant by that third requirement:
Quote:
3. control + y, control + x should be ignored
Taken literally, it means that all occurrences of ctrl-x and ctrl-y should be deleted from the input string. Saying "control x is pressed" and going back to the prompt is not at all like that.

Requirement 2 indicates that keyboard input should be processed only after the <enter> key is pressed, and that also is inconsistent with doing anything immediately when ctrl-x or ctrl-y is pressed. To make the builtin read command return those characters immediately you would have to make it read single characters ("-n 1" option) and do a lot of extra setup and processing. The builtin read command is not well suited for that sort of use.
 
  


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
Bash script help - Capture output of ls - move files according to date wayneywoo Programming 5 04-23-2013 09:45 AM
bash script - capture serial output DEF. Programming 1 06-09-2009 11:07 AM
Bash script to capture pictures using webcam Mogli Linux - Software 27 04-11-2009 02:57 PM
Bash script- capture cdparanoia text output code-breaker Linux - Software 7 08-03-2006 11:13 PM
bash script Want to capture return key and assign a value procfs Programming 9 07-07-2006 02:38 AM


All times are GMT -5. The time now is 02:38 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