Sponsored Content
Top Forums Shell Programming and Scripting In bash, read to a variable with a default value to edit Post 302151336 by porter on Friday 14th of December 2007 02:44:24 PM
Old 12-14-2007
Quote:
Originally Posted by pankai
porter: I wrote a C program using the readline library, but I still don't know how to put the default value after the prompt so the user can edit on the default value. Any idea? Thanks.
Well done, well you officially now know more than me about readline. Are there any examples, documentation with the readline package?
 

10 More Discussions You Might Find Interesting

1. Linux

How to edit /etc/fstab when root was mounted as read only

can somebody help me out in editing the /etc/fstab. I am on RHEL5 (Tikanga). **The problem is that i have given a wrong LABEL in /etc/fstab for root volume and so after reboot, it is unable to resolve the wrong LABEL; so, i have to edit the /etc/fstab :-( -ilan (3 Replies)
Discussion started by: ilan
3 Replies

2. Red Hat

how to edit the bash shell?

Hello friends, I want to add some features to the bash shell.I logged in as the root.Even then could not view the source code of bash shell in RH 9,Fedora 8.It is in encrypted form.Can you please tell me how to include my code into bash shell. Please give me a sample code so that I can understand... (3 Replies)
Discussion started by: nsharath
3 Replies

3. UNIX Desktop Questions & Answers

grub, ok, bash, edit, kmdb and what else?

Hello There is a > prompt at Grub, # prompt for the console and $ for bash, but I am clueless about when and how to get into a specific prompt, how to move around between one prompt to another and how to exit. Is there a very basic guide anywhere that CLEARLY explains the type of shell... (2 Replies)
Discussion started by: mani1413
2 Replies

4. Shell Programming and Scripting

Read and edit multiple files using a while loop

Hi all, I would like to simply read a file which lists a number of pathnames and files, then search and replace key strings using a few vi commands: :1,$s/search_str/replace_str/g<return> but I am not sure how to automate the <return> of these vis commands when I am putting this in a... (8 Replies)
Discussion started by: cyberfrog
8 Replies

5. Shell Programming and Scripting

Edit csv file with bash

I' trying to use bash to edit a csv file from this format: "apples","oranges","grapes" "bread","butter","milk" To this: "apples oranges grapes" So that if I would open the csv file in open office, "apples oranges grapes" Would be in one single cell, and "bread (2 Replies)
Discussion started by: locoroco
2 Replies

6. Shell Programming and Scripting

Help with Bash piped while-read and a read user input at the same time

Hi I am new to writing script and want to use a Bash Piped while-read and read from user input. if something happens on server.log then do while loop or if something happend on user input then do while loop. Pseudocode something like: tail -n 3 -f server.log | while read serverline || read... (8 Replies)
Discussion started by: MyMorris
8 Replies

7. Shell Programming and Scripting

scan and edit in bash

so assume I have a dozen files in local directory and half of them are .txt and I only want to scan these text files and go inside each of them and replace absolute paths (e.g. C:\blabla\more blahblah\myfile.txt) with just the name of that file (myfile.txt) and then go to next line and look if... (6 Replies)
Discussion started by: Jaymz
6 Replies

8. Shell Programming and Scripting

[Bash] Read History function & Read Arrowkeys

Hi. How can I create a history function? (By "read" command or so) & How can I configure a read command so that the arrow keys are not displayed so funny? (^[[A) Thanks in advance. (4 Replies)
Discussion started by: sinnlosername
4 Replies

9. UNIX for Advanced & Expert Users

[BASH] Read value of variable, but not comment on the same line

Heyas So while i'm trying to increase security/usability of my TUI commands, i'm currently at tui-conf-get. There was also a bug, i wanted to fix, but sadly that bugfix is more insecure - but twice as fast as my current buggy method. I've added a getopts toggle, '-s' to toggle beSecure,... (8 Replies)
Discussion started by: sea
8 Replies

10. UNIX for Beginners Questions & Answers

Using read to assign value to bash variable not working

Hi, I am attempting to assign the output of the following command, to two bash variables, var1 and var2 using "read," but it doesn't seem to be working. # openstack hypervisor stats show | awk -F'|' 'NR==14{print $2,$3}' vcpus 92 # echo $? 0 # openstack hypervisor... (4 Replies)
Discussion started by: sand1234
4 Replies
Term::ReadLine(3pm)					 Perl Programmers Reference Guide				       Term::ReadLine(3pm)

NAME
Term::ReadLine - Perl interface to various "readline" packages. If no real package is found, substitutes stubs instead of basic functions. SYNOPSIS
use Term::ReadLine; my $term = Term::ReadLine->new('Simple Perl calc'); my $prompt = "Enter your arithmetic expression: "; my $OUT = $term->OUT || *STDOUT; while ( defined ($_ = $term->readline($prompt)) ) { my $res = eval($_); warn $@ if $@; print $OUT $res, " " unless $@; $term->addhistory($_) if /S/; } DESCRIPTION
This package is just a front end to some other packages. It's a stub to set up a common interface to the various ReadLine implementations found on CPAN (under the "Term::ReadLine::*" namespace). Minimal set of supported functions All the supported functions should be called as methods, i.e., either as $term = Term::ReadLine->new('name'); or as $term->addhistory('row'); where $term is a return value of Term::ReadLine->new(). "ReadLine" returns the actual package that executes the commands. Among possible values are "Term::ReadLine::Gnu", "Term::ReadLine::Perl", "Term::ReadLine::Stub". "new" returns the handle for subsequent calls to following functions. Argument is the name of the application. Optionally can be followed by two arguments for "IN" and "OUT" filehandles. These arguments should be globs. "readline" gets an input line, possibly with actual "readline" support. Trailing newline is removed. Returns "undef" on "EOF". "addhistory" adds the line to the history of input, from where it can be used if the actual "readline" is present. "IN", "OUT" return the filehandles for input and output or "undef" if "readline" input and output cannot be used for Perl. "MinLine" If argument is specified, it is an advice on minimal size of line to be included into history. "undef" means do not include anything into history. Returns the old value. "findConsole" returns an array with two strings that give most appropriate names for files for input and output using conventions "<$in", ">out". Attribs returns a reference to a hash which describes internal configuration of the package. Names of keys in this hash conform to standard conventions with the leading "rl_" stripped. "Features" Returns a reference to a hash with keys being features present in current implementation. Several optional features are used in the minimal interface: "appname" should be present if the first argument to "new" is recognized, and "minline" should be present if "MinLine" method is not dummy. "autohistory" should be present if lines are put into history automatically (maybe subject to "MinLine"), and "addhistory" if "addhistory" method is not dummy. If "Features" method reports a feature "attribs" as present, the method "Attribs" is not dummy. Additional supported functions Actually "Term::ReadLine" can use some other package, that will support a richer set of commands. All these commands are callable via method interface and have names which conform to standard conventions with the leading "rl_" stripped. The stub package included with the perl distribution allows some additional methods: "tkRunning" makes Tk event loop run when waiting for user input (i.e., during "readline" method). "ornaments" makes the command line stand out by using termcap data. The argument to "ornaments" should be 0, 1, or a string of a form "aa,bb,cc,dd". Four components of this string should be names of terminal capacities, first two will be issued to make the prompt standout, last two to make the input line standout. "newTTY" takes two arguments which are input filehandle and output filehandle. Switches to use these filehandles. One can check whether the currently loaded ReadLine package supports these methods by checking for corresponding "Features". EXPORTS
None ENVIRONMENT
The environment variable "PERL_RL" governs which ReadLine clone is loaded. If the value is false, a dummy interface is used. If the value is true, it should be tail of the name of the package to use, such as "Perl" or "Gnu". As a special case, if the value of this variable is space-separated, the tail might be used to disable the ornaments by setting the tail to be "o=0" or "ornaments=0". The head should be as described above, say If the variable is not set, or if the head of space-separated list is empty, the best available package is loaded. export "PERL_RL=Perl o=0" # Use Perl ReadLine without ornaments export "PERL_RL= o=0" # Use best available ReadLine without ornaments (Note that processing of "PERL_RL" for ornaments is in the discretion of the particular used "Term::ReadLine::*" package). CAVEATS
It seems that using Term::ReadLine from Emacs minibuffer doesn't work quite right and one will get an error message like Cannot open /dev/tty for read at ... One possible workaround for this is to explicitly open /dev/tty like this open (FH, "/dev/tty" ) or eval 'sub Term::ReadLine::findConsole { ("&STDIN", "&STDERR") }'; die $@ if $@; close (FH); or you can try using the 4-argument form of Term::ReadLine->new(). perl v5.12.1 2010-05-13 Term::ReadLine(3pm)
All times are GMT -4. The time now is 05:07 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy