Sponsored Content
Full Discussion: KSH command completions.
Top Forums Programming KSH command completions. Post 302518419 by Surendra_Singh on Friday 29th of April 2011 02:52:02 PM
Old 04-29-2011
KSH command completions.

I want to do the Auto command completion in ksh for my product's CLI. For that I am using the key binding mechanism. But am stuck at following points.

1. I am not able to use .sh.edtext variable while KEYBD trap. As I know this variable contains Characters in the input buffer during a KEYBD trap. But in my script, this variable is always NULL. Can you please tell me How can I get the content of input buffer in my script.
2. If somehow I get the input buffer in my script then I have to compute the next possible completions based on the input buffer. Now:
A. If there is only completion.
In this case I have to append this to input buffer and put this new string on command prompt. How can I replace the content of command prompt with new string?
B. If there are more than 1 possible completion:-
I have to show all completions below the command prompt. This I can do with print command. Is there any other ways to do this.

I am using the following script for key bind:-
-------------------------------
typeset -A Keytable
trap 'eval "${Keytable[${.sh.edchar}]}" && VX_COMMAND=${.sh.edtext}' KEYBD
function keybind # key [action]
{
typeset key=$(print -f "%q" "$2")
case $# in
2) Keytable[$1]="$key"
;;
1) unset Keytable[$1]
;;
*) print -u2 "Usage: $0 key [action]"
return 2 # usage errors return 2 by default
;;
esac
}

export VX_COMMAND
keybind $'\Ew' function.sh #I want to bind Alt+w with function.sh and want to use input buffer in function.sh.
---------------------------------------

I didn't found these answers with GOOGLE.
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

printf command in ksh

Hi, I am very confused with my printf command. Somehow one variable can't line up with others... newstart2 ="Mon Nov 11 01 00:00:00 2002" printf "%-20s" $newstart2 Here is the output: Mon Nov 11 01 00:00:00 2002 It spread out to two lines.. Why? (1 Reply)
Discussion started by: cin2000
1 Replies

2. Shell Programming and Scripting

Command taken away from ksh script

Hi, Any help or suggestions would be most appreciated. I am having problems in the latter end of this ksh script where I will be checking two files. If they exist do nothing otherwise I need to reinitialize the database which resides on o/s Aix 5.3. The problem I am facing is when the reinit... (2 Replies)
Discussion started by: hgjdv
2 Replies

3. Shell Programming and Scripting

du command error in ksh

Hi, i am facing an error in the korn shell by executing the following script, can anyone help me out in solving the error.. Note: /root/kamal is a directory size_dir=$(du -s /root/kamal | cut -f1) echo $size_dir error: invalid $ at ( in size_dir Thanks &... (2 Replies)
Discussion started by: G.K.K
2 Replies

4. Shell Programming and Scripting

awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in https://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html#post302255121 Since there were no responses on the parent thread since it got resolved partially i thought to open the new... (4 Replies)
Discussion started by: rajan_san
4 Replies

5. Shell Programming and Scripting

Command substition with KSH

$var=`command <arg> <arg>` I thought there was another method $var=$(command <arg> <arg>) I thought I read saw the second example. It doesnt work (2 Replies)
Discussion started by: popeye
2 Replies

6. Shell Programming and Scripting

rsh command - ksh

Hello, I am trying to run a remote file (y.ksh) using rsh. In this action i want to use an environment variable TOOL=/home/macc1 i am running the rsh from profile macc on server1. rsh server2 -l macc1 "$TOOL/y.ksh" but i can see that the executable command = /home/macc/y.ksh and not... (1 Reply)
Discussion started by: LiorAmitai
1 Replies

7. Shell Programming and Scripting

KSH command completions.

I want to do the Auto command completion in ksh for my product's CLI. For that I am using the key binding mechanism. But am stuck at following points. 1. I am not able to use .sh.edtext variable while KEYBD trap. As I know this variable contains Characters in the input buffer during... (1 Reply)
Discussion started by: Surendra_Singh
1 Replies

8. Shell Programming and Scripting

command timeout in ksh

I probably read all the threads in almost all the forums for a solution to my need. I am a beginner in shell scripting and I dont have a perfect solution yet. Below is my code snippet. idql -n $REPOSITORY_NAME.$cs -Udmadmin -P"" -R$DM_SCRIPTS/test.api > /dev/null 2>&1 if ; then echo... (7 Replies)
Discussion started by: vishnudev1
7 Replies

9. Shell Programming and Scripting

Using awk command in ksh

I am trying to use awk command withing ksh. ksh "echo \"my name\" | awk '{print $2}'" I am getting out as : my name Expected output: name When I use echo "my name" | awk '{print $2}' I am getting the correct output: name I am not sure what mistake I am doing when using awk... (1 Reply)
Discussion started by: Bala_db2
1 Replies
times(1)                                                           User Commands                                                          times(1)

NAME
times - shell built-in function to report time usages of the current shell SYNOPSIS
sh times ksh times DESCRIPTION
sh Print the accumulated user and system times for processes run from the shell. ksh Print the accumulated user and system times for the shell and for processes run from the shell. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
ksh(1), sh(1), time(1), attributes(5) SunOS 5.10 15 Apr 1994 times(1)
All times are GMT -4. The time now is 04:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy