Sponsored Content
Full Discussion: Question about Korn Shell
Top Forums Shell Programming and Scripting Question about Korn Shell Post 42807 by Latha Nair on Tuesday 4th of November 2003 03:37:27 PM
Old 11-04-2003
If I can use the "do" statement, how would I phrase it? I tried the do command in a simple script. It doesn't work.

print -n "Y/N "
read ans
if [ ans = Y ]; do
my_function
else
echo "NOT TRUE"
fi

my_function () {
echo "INSIDE MY FUNCTION"
}

I get the error
./test[4]: 0403-057 Syntax error at line 5 : `do' is not expected.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Question variables Korn

I'm using the following command to test for certain characters in a script echo "${1}" | grep '\$' if (( ${?} == 0 )) then testing this script on the command line I have ksh -x script1.sh "xxxx$xxxx" this works fine but when I want to use ksh -x script1.sh "xxxx $xxx" the... (1 Reply)
Discussion started by: frank
1 Replies

2. Shell Programming and Scripting

AWK question in the KORN shell

Hi, I have two files with the following content: gmrd.txt 235649;03;2563;598 291802;00;2563;598 314634;00;235649;598 235649;03;2563;598 393692;00;2563;598 411805;00;2563;598 411805;00;2563;598 235649;03;2563;598 414037;00;2563;598 575200;00;2563;598 70710;00;2563;598... (11 Replies)
Discussion started by: penfold
11 Replies

3. Shell Programming and Scripting

how to convert from korn shell to normal shell with this code?

well i have this code here..and it works fine in kornshell.. #!/bin/ksh home=c:/..../ input=$1 sed '1,3d' $input > $1.out line="" cat $1.out | while read a do line="$line $a" done echo $line > $1 rm $1.out however...now i want it just in normal sh mode..how to convert this?... (21 Replies)
Discussion started by: forevercalz
21 Replies

4. Shell Programming and Scripting

Korn Shell Loop question

I'm needing help with assigning variables inside a while loop of ksh script. I have an input text file and ksh script below and I'm trying to create a script which will read the input file line by line, assign first and second word to variables and process the variables according to the contents. ... (4 Replies)
Discussion started by: stevefox
4 Replies

5. Shell Programming and Scripting

Korn Shell Coprocess Performance Question

I am wracking my brains over this. I am trying to use a Korn Shell script to execute an Oracle PL/SQL procedure, using the Oracle command line interface (sqlplus). The script starts sqlplus in a coprocess, and the two processes communicate using a two-way pipe. The bgnice option is off, so both... (8 Replies)
Discussion started by: Mark Puddephat
8 Replies

6. Shell Programming and Scripting

korn shell question

Hi all, I am trying to tweak my ksh , i am running V: Version M-11/16/88i I have my Backspace and up/down arrows working using the following code in my ~/.profile file. set -o emacs alias __A=$(print '\020' ) alias __B=$(print '\016' ) alias __C=$(print '\006' ) alias __D=$(print... (4 Replies)
Discussion started by: mich_elle
4 Replies

7. Shell Programming and Scripting

Korn shell and awk question

I am modifying a Korn shell script in using the Exceed (Solaris 10 environment). My task is to read in a .txt file with dates arranged like this (01-Sep-2006). I am to read each line and take the dates, compare them to a benchmark date and depending on if it is older than the date or the date and... (6 Replies)
Discussion started by: mastachef
6 Replies

8. AIX

AIX 4.2 Korn shell and grep question

Ho do I find out the verion of the Kron shell on my client`s system ? There is no one to ask. They are not knowledged enough (hard to believe but yes). Also, on that AIX 4.2, I am trying to figure out how to do a grep using a search patter like below but does not seam to work. The '*' do... (11 Replies)
Discussion started by: Browser_ice
11 Replies

9. Shell Programming and Scripting

Question about a simple Korn script

Hi to everybody! I want to write a simple script in ksh that decrypts and encrypts using the DES algorithm. There is no builtin function in UNIX : i have found only a function in openssl but i don't understand how to use it. The script must accept in input the plaitext and the DESKEY in... (2 Replies)
Discussion started by: kazikamuntu
2 Replies

10. Shell Programming and Scripting

korn shell remove files question

how do you show each filename in a giving directory and delete the specific file in korn script i was thinking using ls rm ? but i cant make it work (0 Replies)
Discussion started by: babuda0059
0 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 05:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy