LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-14-2020, 09:05 PM   #1
BudiKusasi
Member
 
Registered: Apr 2017
Posts: 97

Rep: Reputation: Disabled
execute a readline function inside bash script


How to do or execute a readline function inside bash script as do mimic actual key press ?

such as previous-history, or previous-history repeated thrice, etc etc
 
Old 09-15-2020, 03:20 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 15,140

Rep: Reputation: 4984Reputation: 4984Reputation: 4984Reputation: 4984Reputation: 4984Reputation: 4984Reputation: 4984Reputation: 4984Reputation: 4984Reputation: 4984Reputation: 4984
I think I do not understand. An interactive shell can wait for keypress, but a running shell script does not. There is a function read if you need some user interaction.
Also there is a history file to check the previous commands (of an interactive shell), but that is a file, not keypress.
Would be nice to know what do you want to achieve.
 
Old 09-15-2020, 11:11 AM   #3
akakingess
Member
 
Registered: Jun 2009
Location: Houston, Texas
Distribution: Ubuntu
Posts: 62

Rep: Reputation: 17
Quote:
Originally Posted by pan64 View Post
I think I do not understand. An interactive shell can wait for keypress, but a running shell script does not. There is a function read if you need some user interaction.
Also there is a history file to check the previous commands (of an interactive shell), but that is a file, not keypress.
Would be nice to know what do you want to achieve.
I believe OP is looking for a way to emulate the "up arrow" which will pull the last command entered (and of course up arrow 3 times would go back 3 commands historically).
 
1 members found this post helpful.
Old 09-15-2020, 11:31 AM   #4
boughtonp
Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 600

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380

The Bash built-in "read" uses readline when the -e option is provided.

If that's not what the OP wants then they need to more clearly state what they want and what they are trying to achieve.

 
  


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
every hour run a bash function inside a bash shell Skaperen Programming 43 06-01-2020 02:55 PM
Patch for readline.SlackBuild to include rlfe (ReadLine Fron-End) tfonz Slackware 0 10-22-2016 11:45 AM
Push output string from script directly into bash / readline command input buffer GreyBeard Linux - Software 3 02-20-2012 11:26 PM
Using cat readline within cat readline while loop demxkn66 Programming 5 12-16-2007 05:10 PM
Execute bash script inside PHP creatorrr Programming 11 11-21-2007 04:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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