PERL to ksh


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PERL to ksh
# 1  
Old 02-12-2014
PERL to ksh

Hi,

I have perl code inside my script.

Code:
while (1) {
* * * * *print "Enter 'n' for New , 'e' for Existing or 'q' to quit: ";
* * * * *chomp($response = <STDIN>);
* * * * *die "Exiting Process \n" if $response =~ /^q$/i;
* * * * *last if $response =~ /^[ne]$/i;
* * * * *print "Invalid entry - enter 'n', 'e', or 'q' \n";
}


I want to write same thing in KSH . any ideas for while(1) quilent in KSH ?

Thanks
# 2  
Old 02-12-2014
What are the "* * * * *" ? That does not look like valid perl.

Code:
RESPONSE=""

while ! [ "$RESPONSE" = "q" ]
do
        printf "Enter 'n' for New , 'e' for Existing or 'q' to quit: "
        read RESPONSE
        case "$RESPONSE" in
        n)     echo "code for n"
                ;;
        e)     echo "code for existing"
                ;;
        q)     ;; # Do nothing, let the while-loop break
        *)     echo "Invalid option, try again"
                ;;
        esac
done

This User Gave Thanks to Corona688 For This Post:
# 3  
Old 02-12-2014
Thanks ... when copied from word doc, it added those characters.

Thanks
# 4  
Old 02-12-2014
One keystroke way (bash):
Code:
while true
do
   read -r -p "Enter 'n' for New , 'e' for Existing or 'q' to quit: " -n 1 response
   [ "${response}." = "q." ] && echo -e "\nExiting Process" && exit
   [ "${response}." = "n." -o "${response}." = "e." ] && break
   echo -e "\nInvalid entry - enter 'n', 'e', or 'q'"
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl : Perl equivalent to the ksh | and ;

Ive been trying to move to Perl. It has been a struggle. My question is, is there a good resource that explains nesting statements. As an example. To change primary Factory CTS 1.9.0(46) P1 *Slot 1 CTS 1.10.2(42) P1 To primary *Slot 1 CTS 1.10.2(42) P1 ... (5 Replies)
Discussion started by: popeye
5 Replies

2. Shell Programming and Scripting

Ksh/perl banner - is there one :(-

Hi, Our Red Hat Linux machines, unlike Solaris, do not have the banner command. I am not the SA for these machines and the SA refuses to put in banner. Not sure what is his main objection to it, but he just flatly say no, end of story. I am using banner as a quick way of identifying the... (2 Replies)
Discussion started by: newbie_01
2 Replies

3. Shell Programming and Scripting

ksh: <a perl file name> not found

I am using a perl file to run a batc job from unix prompt. I am inside the correct directory where the perl file is located. I can even find the file using ls command. But when I run the perl file , it says 'ksh: <perl_file.pl> not found'. Could anyone please let me know what is wrong? (4 Replies)
Discussion started by: Subhasis
4 Replies

4. Shell Programming and Scripting

ksh vs perl strange interaction.

Hello everybody, I isolated an issue: please try the following script (under AIX) #!/usr/bin/ksh93 echo "Before Perl: \c" read line echo "|$line|" perl -e 'print "Perl invocation";' echo echo "After Perl: \c" read line echo "|$line|" On the first input, type Ctrl-D. It works... (13 Replies)
Discussion started by: jlovi
13 Replies

5. Shell Programming and Scripting

Using Perl Inside KSH

Hi there, I am new to Perl and KSH. The system I am using picks up the KSH scripts and uses them in a batch job control system. I am trying to set a variable from a perl command #!/bin/ksh -eaxp #******************************************************************************* # Testing... (5 Replies)
Discussion started by: SaadLive
5 Replies

6. Shell Programming and Scripting

Need to convert ksh script to Perl

Guys I am new to this forum, this may seem like a cheeky request. I have been asked by my manager to convert this ksh script to Perl. I do not have the foggiest about Perl and would appreciate any help on this. Basically this scipt automates a recovery process for EMC Legato Networker. It will... (1 Reply)
Discussion started by: rahimm1
1 Replies

7. Shell Programming and Scripting

Perl in KSH - julian conversion

Hello Everyone, I have this code misbehaving in one of my scripts, I have a var containing the sequential number of the day for the year and I am suppose to get the regular date for that day and its weekday. If I set the day to 273 I get back 2008/09/31 which is not a proper date. can you help... (7 Replies)
Discussion started by: gio001
7 Replies

8. Shell Programming and Scripting

Embedding Perl construct in ksh...

Hi, I have an embedded Perl construct in a korn script. However, I cannot seem to access the shell variables that were declared outside this Perl section. This is how my script is written....I have also tried back-ticks where I assign the shell variable to my local perl variable, still... (1 Reply)
Discussion started by: svetlur
1 Replies

9. Shell Programming and Scripting

accessing a function in ksh from perl

is it possible? Because I know we could use open(A, `abc.ksh`); to access a ksh, but is it possible to access just one (or more) function from the ksh script? (2 Replies)
Discussion started by: ahtat99
2 Replies

10. Shell Programming and Scripting

Invoke perl program from Ksh

Hi all, Can I invoke a perl script from Ksh script and pass parameters to the perl script. Please do help me.. thanks Maha (10 Replies)
Discussion started by: mahalakshmi
10 Replies
Login or Register to Ask a Question