![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to write to stdin of another program (program A -> [stdin]program B) | vvaidyan | UNIX for Dummies Questions & Answers | 3 | 08-02-2008 05:21 PM |
| How to write to stdin of another program (program A -> [stdin]program B) | vvaidyan | High Level Programming | 1 | 04-30-2008 01:44 PM |
| Need help with shellscript | jigarlakhani | Shell Programming and Scripting | 2 | 11-22-2007 08:28 AM |
| HOWTO: Calculate the balance of work in multi-threaded app. | DreamWarrior | High Level Programming | 2 | 11-01-2006 10:54 AM |
| ftp in Shellscript | ggowrish | UNIX for Advanced & Expert Users | 3 | 06-11-2004 08:09 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Howto get readline to work in shellscript (stdin)
GNU readline works fine on my system.
But my shell script takes stdin from user such as : cat >> filename. I want to be able to use editing commands on the stdin. Currently, I am unable to even reedit the existing line (go back over what has been typed other than backspace which deletes). How can i get readline to work on stdin. If it is not possible with "cat" is there some other command i can use ? Thanks. |
|
||||
|
Thanks, yes that does work. However, it works for one line. With cat I would need to use multiple lines. Let me see if I can find someway to do that. A loop perhaps -- while read -e line -- let me try it out and get back.
I did find something called "rlwrap" that works well. I do "rlwrap cat >> filename". You can wrap any command with rlwrap. After trying rlwrap in my shellscript, my requirements increased! Now I would like to go up and edit the previous line, too. (Why can't I just invoke vi and stop being geeky!). (iirc, zsh allows that). |
|
||||
|
Never let it be said that "it can't be done", but I think it'd be difficult to find something that would do that. The reason being that vi uses the terminal in "curses" mode, where the positions of every character visible on the terminal are managed explicitly by the application.
When the terminal is not in this mode it operates in a line by line "stream" fashion, where the shell throws characters at the terminal in a reasonably organised order, but does not track what happens to them after that, so is incapable of going back to previous lines to edit them. I think anything you do to try and combine the two will result in something with limited portability and plenty of potential for unexpected behaviour. |
![]() |
| Bookmarks |
| Tags |
| shell script. gnu readline |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|