\c showing in ksh


 
Thread Tools Search this Thread
Operating Systems Linux \c showing in ksh
# 1  
Old 03-17-2010
Java \c showing in ksh

Hi,

I am having an issue releated to shell-environment on a server.

Let me explain with the example of below script:
Code:
#!/bin/ksh
 
echo " enter:\c"
read a
echo $a

As I am using ksh the expected output from this script should be 'enter:' (expecting the input for read in same line)
However, the output that I am getting is enter:\c ( which is expecting the input for read in next line).

Please suggest how to solve this issue?Smilie

I cannot use another shell here as the application that I am using has multiple scripts in ksh only.

//Thanks in advance
Mayaank

Last edited by mystition; 03-17-2010 at 08:38 AM.. Reason: code tags, please...
# 2  
Old 03-17-2010
Which version of ksh are you using? Because with ksh93 it works fine:
Code:
$ echo ${.sh.version}
Version M 1993-12-28 s+
$ type echo
echo is a shell builtin
$ echo " enter:\c"
 enter:$
$ which ksh
/usr/bin/ksh
$

# 3  
Old 03-17-2010
Data

Hi Pludi,

I am getting the following:

Code:
[root@xxx ~]# su - xxxx
$ ksh
$ 
$ 
$ echo ${.sh.version}
Version M 93s+ 2008-01-31
$ 
$ type echo
echo is a shell builtin
$ echo " enter:\c"
 enter:\c
$ which ksh
/bin/ksh
$


Last edited by pludi; 03-17-2010 at 07:46 AM.. Reason: code tags, please...
# 4  
Old 03-17-2010
Might be that it's rather got something to do with the way your terminal interprets escape sequences than with the shell itself, as it's even working with ksh88 on HP-UX and pdksh on Linux.

But there's a workaround. Instead of
Code:
echo " enter:\c"

use
Code:
printf " enter:"

# 5  
Old 03-17-2010
Just to add that the behavior of echo when the first arg does not begin with a -, and none of the arguments contain a \, is defined as system dependent in the ksh93 man pages.

Code:
echo [  arg  . . .  ] When the first arg  does not begin with a -, 
and none of the arguments contain a \, then echo prints each of
 its arguments separated by a space and terminated by a new-line.
 Otherwise, the behavior of echo is system dependent and print or
 printf described below should be used. See echo(1) for usage and
 description.

As already stated, you could (and in my opinion you should) use printf instead of echo.

Other workarounds are:

Code:
echo -n enter:
echo -e 'enter:\c'

# 6  
Old 03-17-2010
Java

Thanks for your reply Pludi and Radoulov,

Even when I am trying to run the same on other servers with older ksh versions, it is working for me.

This issue is only occuring on a server on which a newer version of GNU/Linux has been installed.

The workaround that you have suggested might not be able to help me as this issue is affecting multiple scripts in a particular application.

Is there any way to solve this wothout getting on an older linux version?
# 7  
Old 03-17-2010
I don't know other workaround(s).
The usage of echo in shell scripts is discouraged because of the issues you're facing now.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Showing 4 digits

Hello everybody I'm a little beginer for shell script as I started last night... I have this script cat fichier.txt | while read l ; do #echo $l echo $x x=$(( $x + 1 )) done it's return 1 2 3 4 (4 Replies)
Discussion started by: remibemol
4 Replies

2. Shell Programming and Scripting

Showing error

if ; then rm -rf "${x}"_"${y}"_abc_pqr.dat error: `then' unmatchedCan anyone please help me in correcting it. Please use code tags next time for your code and data. Thanks (2 Replies)
Discussion started by: D_Sethi
2 Replies

3. UNIX for Dummies Questions & Answers

Showing Clock

Is it possible to display the clock (timing) on the screen all the time. (3 Replies)
Discussion started by: vino.paal
3 Replies

4. Emergency UNIX and Linux Support

Vsftpd Not showing icons

Hi guys. I have configured ftp server with vsftpd. now here is the crazy question: vsftpd does not show icons besides folders and files and also it doesn't show folder sizes. (4 Replies)
Discussion started by: majid.merkava
4 Replies

5. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

6. AIX

5.2 who not showing all login

I have 1 box running 5.2 and another running 5.3. Both use the NIS accounts and NFS home directories. Users can telnet on to both and 'who' displays the login. However when users run xterms using a remote X server (e.g. Exceed), by telnetting then running /usr/bin/X11/xterm -d xxx.xxx.xxx.xxx:0 ... (1 Reply)
Discussion started by: spitzie
1 Replies

7. AIX

san lv showing old fs

Hi All, I have been working with two AIX with san and this is the first I got this minor problem on my third AIX. The san/hdisk was recreated so many times because of this problem. When I created a new vg and fs. The fs will be mounted/unmounted properly but if I query the fs on a vg with... (2 Replies)
Discussion started by: itik
2 Replies

8. Post Here to Contact Site Administrators and Moderators

Posts not showing up

I received the following e-mail notification, but neither this post nor my previous post is showing up. ---------------------------------------------------------------- patwa has just replied to a thread you have subscribed to entitled - Waiting between commands - in the UNIX for Dummies... (1 Reply)
Discussion started by: cfajohnson
1 Replies

9. Shell Programming and Scripting

Showing that something is deleteing

Hi there, I have a scritp that is clearing out old files from some directories, rather than echoing the name of the file when it gets deleted i want to echo a ". " I have tried to just echo it after the deletion but it lists like this . . . . I want to show it like this . . . . . . . . .... (1 Reply)
Discussion started by: nhatch
1 Replies

10. UNIX for Dummies Questions & Answers

ps -ef not showing all info

Hi there, How can I expand the command filed sizing when using a ps command. With diretories and script names and parameters being set I'm not getting some of the information that I need (at the end of the command line). I'm using HP_UX 11i. Cheers, Neil (2 Replies)
Discussion started by: nhatch
2 Replies
Login or Register to Ask a Question