ksh vs perl strange interaction.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ksh vs perl strange interaction.
# 8  
Old 01-10-2011
Do a "stty -a". Isn't a cntl-D your eof character? eof means "end of file". You are not supposed to continue reading after eof. You could try to reopen the terminal with "exec < /dev/tty".
# 9  
Old 01-10-2011
I believe that something else is going on. Using ksh93, I do not need to enter Ctrl-D twice on any platform and read works exactly as documented.

If you spell out your exact requirements, we can probably solve your problem for you in a simple manner. Are you logged in at the console or on some remote terminal/terminal emulator?
# 10  
Old 01-10-2011
Quote:
Originally Posted by Perderabo
Do a "stty -a";. Isn't a cntl-D your eof character? eof means &quot;end of file&quot;. You are not supposed to continue reading after eof. You could try to reopen the terminal with ";exec < /dev/tty";.
Hello, I tried you suggestion. Doesn't work either. Anyway, this code requires 2 x Ctrl-D, the first time:

Code:
echo a|read a
read line

No Ctrl-D read in the first read.

---------- Post updated at 07:18 PM ---------- Previous update was at 07:14 PM ----------

Quote:
Originally Posted by fpmurphy
I believe that something else is going on. Using ksh93, I do not need to enter Ctrl-D twice on any platform and read works exactly as documented.

If you spell out your exact requirements, we can probably solve your problem for you in a simple manner. Are you logged in at the console or on some remote terminal/terminal emulator?
Indeed, Ctrl-D is the EOF, as shown in stty -a

However, this doesn't work either, where no Ctrl-D is involved in the first line.

Code:
 echo "a"|read a
 readline

Adding exec < /dev/tty between the two statements doesn't help.

I'm using Konsole in Fedora/KDE. Tried with another terminal. Same result.

Code:
 [root@BE01850T400 ~]# rpm -qf $(which konsole)
 kdebase-4.4.5-1.fc12.i686


Last edited by jlovi; 01-10-2011 at 02:02 PM..
# 11  
Old 01-10-2011
Jlovi, you started off with a purported problem with ksh93 on AIX. Now you are talking about Konsole on Fedora/KDE using readline. What exactly are you trying to achieve, under what shell and on what platform? You need to spell it out for us!
# 12  
Old 01-10-2011
Quote:
Originally Posted by fpmurphy
Jlovi, you started off with a purported problem with ksh93 on AIX. Now you are talking about Konsole on Fedora/KDE using readline. What exactly are you trying to achieve, under what shell and on what platform? You need to spell it out for us!
My stations is a Fedora/KDE system, I use Konsole in order to connect to an AIX server, using ssh. The script runs on the AIX server. You were talking of terminal issues, that's why I mentionned my workstation. And "read line" is in two words Smilie.

However, I'm a bit skeptical about a terminal issue since it works in ksh88, but not in ksh93. Looks like a specific bug or feature. IMHO, ksh93 is not as stable as ksh88, as I get something coredumps in ksh93 for things that work in ksh88.

Currenly my script works perfectly in ksh88 but I have experimental code that requires ksh93 (for keybinding), that's why I'd like to make it work with this latest version of ksh.

Last edited by jlovi; 01-10-2011 at 03:24 PM..
# 13  
Old 01-10-2011
Quote:
Originally Posted by jlovi
Got something like this:

Code:
#!/usr/bin/ksh93
line=$(trap 'line=""' INT;head -1|(set -f;read -r line;print -r "$?:$line") 2> /dev/null)
[ "X$line" != "X" ] && read_res=$(print -r "$line"|cut -f1 -d:)
line=$(print -r "$line"|cut -f2- -d:)

Tested successfully on Linux (Fedora) and AIX

Works in ksh. Core dump in ksh93! Smilie
Your script works fine and no Core dump in AIX 5.3:
Code:
$ oslevel -s
5300-10-00-0000
$ what /bin/ksh93 | grep Version
        Version M-12/28/93e
$ cksum /bin/ksh93
1875805810 791843 /bin/ksh93

# 14  
Old 01-11-2011
Quote:
Originally Posted by Chubler_XL
Your script works fine and no Core dump in AIX 5.3:
Code:
$ oslevel -s
5300-10-00-0000
$ what /bin/ksh93 | grep Version
        Version M-12/28/93e
$ cksum /bin/ksh93
1875805810 791843 /bin/ksh93

Did you try to type Ctrl-C?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[Perl] Strange problem with array

Hi, I have a strange problem with arrays in Perl. That is to say, for me it is strange and perhaps there is a special reason for it that I do not know of. Not a real Perl Ace. This is the program, as an example: #!/usr/bin/perl -w #-d use strict; my $pu; my $pu_list_cmd; my... (2 Replies)
Discussion started by: ejdv
2 Replies

2. Shell Programming and Scripting

Strange behaviour with perl i/o?

Hi All, I got a strange problem here. I have a perl script which is fetching data from a database table and writing a file with that data. If i run that script from linux command line, the file it creates is a normal ascii text file without any binary character in it.But... (9 Replies)
Discussion started by: DILEEP410
9 Replies

3. Shell Programming and Scripting

strange ksh arithmetic

Hello, I would like to understand this... I'm using ksh and doing (( z = y - 1 )) if y=34, then the result for z is 33, but if y=034 the result is z=27. Why?? Thanks (15 Replies)
Discussion started by: fbg
15 Replies

4. UNIX for Advanced & Expert Users

Strange KSH behaviour - any comments?

As you are probably aware, $# indicates the number of parameters passed into a korn shell script. But this appears to hang around for sunsequent runs...???? A simple script:- #!/usr/bin/ksh echo "#parameters $#" echo "\$1 $1" echo "\$2 $2" I run the script with 0 parameters (all fine) #... (7 Replies)
Discussion started by: gsw_aix
7 Replies

5. UNIX for Dummies Questions & Answers

Longer commands and strange behaviour on ksh

Hi, I was trying to customize this archaic HP-UX box. only shell available is ksh and that too seems to be pretty old and doesn't completely conform to what I read on the web about ksh. Anyway here are my issues: - I wanted to have a dynamic title on xterm or dtterm. I put the following lines... (2 Replies)
Discussion started by: anurags
2 Replies

6. Shell Programming and Scripting

Strange parameter passing problems (KSH)

Hi all, I'm having a rather peculiar problem involving parameter passing with declared functions in my shell script. Hope to get some advice here. A brief description of my code is as follows: However, I'm not getting the results I wanted. If I pass in $rdir, I'm going to end up... (4 Replies)
Discussion started by: rockysfr
4 Replies

7. Shell Programming and Scripting

ksh and awk interaction

in a ksh script, i want to process some string variables using awk, and then i want to go on using this variables in the same ksh (out of awk lines) can anybody send me a very simple example about this? (0 Replies)
Discussion started by: gfhgfnhhn
0 Replies

8. Shell Programming and Scripting

Strange behavior from 'read' statements. (ksh - but could be same on other shells)

I'm getting rather frustrated with an interactive script I'm writing. The script is divided up, with section for setting variable at the top, then functions (which make up most of the script) then basically a line at the end which calls the first function- the program moves between the... (5 Replies)
Discussion started by: alexop
5 Replies

9. Shell Programming and Scripting

bash and Perl interaction questions

hi. i´m working in bash and am trying to create a Perl daemon that controls bash´s behavior. this is actually in preparation for a later project i´ll be working on. basically, i´m looking for a way to have the Perl daemon tell bash what to do. i already have a small daemon that simply prints... (2 Replies)
Discussion started by: deryk
2 Replies
Login or Register to Ask a Question