Sponsored Content
Top Forums Shell Programming and Scripting Displaying default values when accepting input from user Post 302464901 by flopster on Thursday 21st of October 2010 09:09:32 AM
Old 10-21-2010
nope, chubler's solution works perfectly for me ..

thanks
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Accepting User Input

I'm just starting out with UNIX and have figured some stuff out. I just need some help with accepting user input on the command line. For instance, I created a number counter that counts down from any positive hard coded number. But, I want the commnad line line to read "Countdown 20" where 20... (1 Reply)
Discussion started by: scott78
1 Replies

2. Linux

Why isn't the computer accepting input?

I'm using Red Hat Linux 3, and the computer has stopped taking input from mouse, keyboard, etc. What are possible causes? How can I fix? -Worried Linux User (11 Replies)
Discussion started by: lunchtime
11 Replies

3. Shell Programming and Scripting

Accepting user input in Bourne shell and using sed

He guys. Basically I want to make a script that can add, delete and view stuff in a external file called config.txt. I can open it up in Joe but im not sure how to read in the user input or using commands automatically in joe to edit, save then quit. Problem area below: 1) echo "Add... (1 Reply)
Discussion started by: Pits
1 Replies

4. Shell Programming and Scripting

Accepting user input in c shell

i need to accept the user input in my c shell script before executing next command. i have the following code which ask for user input, but does not store this value. set req echo " Enter your input(Y/N)?" read req if (req = Y) echo " print $req" else echo " print $req" ... (3 Replies)
Discussion started by: skumar11
3 Replies

5. UNIX for Dummies Questions & Answers

How to display values from user input array?

Hi all, I wrote a script that reads inputs from user and store in array named "input". The number of elements in the array is not fixed - determined only after user exit the while loop that reads the array values : x=1 echo "Enter first value" read input while } != "exit" ] do ... (1 Reply)
Discussion started by: luna_soleil
1 Replies

6. UNIX for Dummies Questions & Answers

accepting input date

I how do i accept a input date in script which is lesser than a specified day? ex: to accept a date less than or equal to 100 days(from today).?:( Thanks for the help in advance.:) (1 Reply)
Discussion started by: abhi_123
1 Replies

7. Shell Programming and Scripting

Accepting user input and arguments in PERL

Hi All, Can we pass arguments while calling the perl script and as well as ask user input during execution of the script? My program is as below: I am passing arg1 and arg2 as argements to test.pl ]./test.pl arg1 arg2 Inside the test.pl I have : print "Do you want a name ? (y/n) : ";... (2 Replies)
Discussion started by: jisha
2 Replies

8. Shell Programming and Scripting

Accepting Input regardless of Case

Hi I am trying to get my script to accept input regardless if the person enters a or A. here is the portion of the code where I get the input. echo -n 'Please enter your choice:' # prompt user for input. read reply # read input echo case $reply in #... (2 Replies)
Discussion started by: DualPandas
2 Replies

9. Programming

Filling the class from values taken from user input

I have a program that accepts user input. For example I have mdacc that the user sets the value. I then have a class which stores the value set by the user. I use set_param to set the values in the class. I pass through it the list of user defines arguments from argv. What would be the opinion on... (0 Replies)
Discussion started by: kristinu
0 Replies

10. Shell Programming and Scripting

Capturing multiple values from user input

Hello, I need to capture multiple values from user input and do not know how to do it. I'm writing a script to delete old files, but want to give the option to keep some by asking the user. This is what my output looks like... Old files to be deleted... 1 file1 2 file2 Then this bit of... (3 Replies)
Discussion started by: jrymer
3 Replies
Shell::Perl(3pm)					User Contributed Perl Documentation					  Shell::Perl(3pm)

NAME
Shell::Perl - A read-eval-print loop in Perl SYNOPSYS
use Shell::Perl; Shell::Perl->run_with_args; DESCRIPTION
This is the implementation of a command-line interpreter for Perl. I wrote this because I was tired of using irb when needing a calculator with a real language within. Ah, that and because it was damn easy to write it. This module is the heart of the pirl script provided with Shell-Perl distribution, along with this module. EXAMPLE SESSION $ pirl Welcome to the Perl shell. Type ':help' for more information pirl @> 1+1 2 pirl @> use YAML qw(Load Dump); () pirl @> $data = Load("--- { a: 1, b: [ 1, 2, 3] } "); { a => 1, b => [1, 2, 3] } pirl @> $var = 'a 1 2 3'; $var =~ /(w+) (d+) (d+)/ ("a", 1, 2) pirl @> :q COMMANDS Most of the time, the shell reads Perl statements, evaluates them and outputs the result. There are a few commands (started by ':') that are handled by the shell itself. :h(elp) Handy for remembering what the shell commands are. :q(uit) Leave the shell. The Perl statement "exit" will work too. SYNONYMS: :exit, :x :set out (D|DD|DDS|Y|P) Changes the dumper for the expression results used before output. The current supported are: D "Data::Dump" DD "Data::Dumper", the good and old core module DDS "Data::Dump::Streamer" Y "YAML" P a plain dumper ("$ans" or "@ans") When creating the shell, the dump format is searched among the available ones in the order "D", "DD", "DDS", "Y" and "P". That means Data::Dump is preferred and will be used if available/installed. Otherwise, Data::Dumper is tried, and so on. Read more about dumpers at Shell::Perl::Dumper. :set ctx (scalar|list|void|s|l|v|$|@|_) Changes the default context used to evaluate the entered expression. The default is 'list'. Intuitively, 'scalar', 's' and '$' are synonyms, just like 'list', 'l', and '@' or 'void', 'v', '_'. There is a nice way to override the default context in a given expression. Just a '#' followed by one of 'scalar|list|void|s|l|v|$|@|_' at the end of the expression. pirl @> $var = 'a 1 2 3'; $var =~ /(w+) (d+) (d+)/ ("a", 1, 2) pirl @> $var = 'a 1 2 3'; $var =~ /(w+) (d+) (d+)/ #scalar 1 :reset Resets the environment, erasing the symbols created at the current evaluation package. See the section "ABOUT EVALUATION". METHODS Remember this is an alpha version, so the API may change and that includes the methods documented here. So consider this section as implementation notes for a while. In later versions, some of these information may be promoted to a public status. Others may be hidden or changed and even disappear without further notice. new $sh = Shell::Version->new; The constructor. run_with_args Shell::Perl->run_with_args; Starts the read-eval-print loop after reading options from @ARGV. It is a class method. If an option -v or --version is provided, instead of starting the REPL, it prints the script identification and exits with 0. $ pirl -v This is pirl, version 0.0017 (bin/pirl, using Shell::Perl 0.0017) run $sh->run; The same as "run_with_args" but with no code for interpreting command-line arguments. It is an instance method, so that "Shell::Perl-"run_with_args> is kind of: Shell::Perl->new->run; eval $answer = $sh->eval($exp); @answer = $sh->eval($exp); Evaluates the user input given in $exp as Perl code and returns the result. That is the 'eval' part of the read-eval-print loop. print $sh->print(@args); Prints a list of args at the output stream currently used by the shell. help $sh->help; Outputs the help as provided by the command ":help". reset $sh->reset; Does nothing by now, but it will. dump_history $sh->dump_history(); $sh->dump_history($file); Prints the readline history to "STDOUT" or the optional file. Used to implement experimental command ":dump history". This is experimental code and should change in the future. More control should be added and integrated with other terminal features. set_ctx $sh->set_ctx($context); Assigns to the current shell context. The argument must be one of " ( 'scalar', 'list', 'void', 's', 'l', 'v', '$', '@', '_' ) ". set_package $sh->set_package($package); Changes current evaluation package. Doesn't change if the new package name is malformed. set_out $sh->set_out($dumper); Changes the current dumper used for printing the evaluation results. Actually must be one of "D" (for Data::Dump), "DD" (for Data::Dumper), "DDS" (for Data::Dump::Streamer), "Y" (for YAML) or "P" (for plain string interpolation). prompt_title $prompt = $sh->prompt_title; Returns the current prompt which changes with executable name and context. For example, "pirl @>", "pirl $>", and "pirl >". quit $sh->quit; This method is invoked when these commands and statements are parsed by the REPL: :q :quit :x :exit quit exit It runs the shutdown procedures for a smooth termination of the shell. For example, it saves the terminal history file. GORY DETAILS
ABOUT EVALUATION When the statement read is evaluated, this is done at a different package, which is "Shell::Perl::sandbox" by default. So: $ perl -Mlib=lib bin/pirl Welcome to the Perl shell. Type ':help' for more information pirl @> $a = 2; 2 pirl @> :set out Y # output in YAML pirl @> \%Shell::Perl::sandbox:: --- BEGIN: !!perl/glob: PACKAGE: Shell::Perl::sandbox NAME: BEGIN a: !!perl/glob: PACKAGE: Shell::Perl::sandbox NAME: a SCALAR: 2 This package serves as an environment for the current shell session and :reset can wipe it away. pirl @> :reset pirl @> \%Shell::Perl::sandbox:: --- BEGIN: !!perl/glob: PACKAGE: Shell::Perl::sandbox NAME: BEGIN TO DO
There is a lot to do, as always. Some of the top priority tasks are: o Accept multiline statements;. o Refactor the code to promote easy customization of features. SEE ALSO
This project is hosted at Google Code: http://code.google.com/p/iperl/ To know about interactive Perl interpreters, there are two FAQS contained in perlfaq3 which are good starting points. Those are How can I use Perl interactively? http://perldoc.perl.org/perlfaq3.html#How-can-I-use-Perl-interactively%3f Is there a Perl shell? http://perldoc.perl.org/perlfaq3.html#How-can-I-use-Perl-interactively%3f An extra list of Perl shells can be found here: http://www.focusresearch.com/gregor/document/psh-1.1.html#other_perl_shells BUGS
It is a one-line evaluator by now. I don't know what happens if you eval within an eval. I don't expect good things to come. (Lorn who prodded me about this will going to find it out and then I will tell you.) There are some quirks with Term::Readline (at least on Windows). There are more bugs. I am lazy to collect them all and list them now. Please report bugs via CPAN RT <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Shell-Perl> or <mailto://bugs-Shell-Perl@rt.cpan.org>. AUTHORS
Adriano R. Ferreira, <ferreira@cpan.org> Caio Marcelo, <cmarcelo@gmail.com> COPYRIGHT AND LICENSE
Copyright (C) 2007aXX2011 by Adriano R. Ferreira This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2011-03-13 Shell::Perl(3pm)
All times are GMT -4. The time now is 04:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy