04-09-2006
Any numbered list will look like a select menu. There is no direct way to do anything with the list. (Cut and paste using x or windows doesn't count...the question is looking for functionality built into ksh itself.) There is a sequence of operations that can exploit that list somewhat. The only time I ever use it is just to show that it is possible. Most of the time you would be better off just typing "testb" or whatever. I usually work in emacs mode. But it looks like vi mode can do it too.
root# ls
testa testb
root# cat tes[ESC][=]
1) testa
2) testb
root# cat tes <-- what to do now?
Type * to replace "tes" with "testa testb" on the command line.
root# cat testa testb
Type [Esc][#] to turn the current line into a comment and drop it in your history file.
Now you retype your command but now you can extract words from the previous (commented) command in you history. Item n in the list you displayed is word n+1. So for example, "testb" is item 2 in the list and thus word 3 in the previous list. To extract word 3...
cat[Esc]3_
root# cat testb
Note that we did not need a space after the t in "cat". In this case, it so happens that we want the last word of the previous command. So we actually could have omitted the 3. The default is the last word. With enough complex filenames this technique could, in theory, be useful. I know, this isn't what you were looking for. But it is the the closest I can come to exploiting that numbered list of filenames.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
Is there some way to get formatted output in ksh? Something like a properly alligned tabular format. I tried adding '\t' to echo statements, but it doesn't come properly alligned
'hello' A simple Hello
'helloworld' A helloworld statement
I need the second coloumn to... (1 Reply)
Discussion started by: psynaps3
1 Replies
2. Shell Programming and Scripting
Hi guys...
I have a ksh shell by default, so when I login to my unix box, all my .profile statements gets executed(including the aliases).
But for some reasons(may be not comfortable using ksh), I would always switch to BASH(in the same session but as a child process) but in the process I am... (16 Replies)
Discussion started by: anduzzi
16 Replies
3. Shell Programming and Scripting
Hello,
I have a simple question, some scripts have information output on the first of command output such as:
>copyrights by CFIL v1.0
>
>1
>1
>1+1=2
How can I customize the output so I could delete the first line which has copyright line and also the second line which is blank
for... (4 Replies)
Discussion started by: CFIL
4 Replies
4. Shell Programming and Scripting
I have a ksh script written by someone... now i am trying to modify it to my requirement....
Its executed like this
Read.ksh load ${CUR_MAINT_DATE}
if
then
filnam="Load_CLM"
else
filnam="${1}"
fi
if
then
CUR_MAINT_DATE="${2}"
fi
if
then
ls... (1 Reply)
Discussion started by: bhagya2340
1 Replies
5. Shell Programming and Scripting
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. Shell Programming and Scripting
Hi! I am having a bit of a problem with my script. There are two different date formats that may appear in a file, either Jul-12 or Jul--6. I tried to create an if statement that searches for one of the formats and if that doesn't exist searches for the other, however it doesn't seem to be... (3 Replies)
Discussion started by: ther2000
3 Replies
7. Solaris
Hi All, I have the below simple script.
It runs just fine by itself when I manually invoke it.
But once I put it in the crontab with entry:
* * * * * /users/myuser/test.ksh >> /users/myuser/log/test.txt"
It does NOT print the returned value ($REMAIN) from the DB!?
The result in the... (3 Replies)
Discussion started by: steve701
3 Replies
8. Shell Programming and Scripting
Hi,
I came across a post wherein you can use "set -r"(on bash) to activate restricted mode ( wherein you cant run some commands such as cd etc).
Can anyone guide if we have anything similar in ksh ?
Thanks (2 Replies)
Discussion started by: Shivdatta
2 Replies
9. Shell Programming and Scripting
Hi ,
I'm writing the for loop script in home directory and wanted to get the files from /etc/data directory.
#!/bin/ksh
file_nm="/etc/dat"
for test_data in $file_nm/fln*
do
echo "$test_data"
done
the code is executing successfully , but in the output it is showing
... (6 Replies)
Discussion started by: smile689
6 Replies
10. Shell Programming and Scripting
Hi,
How can I redirect the output of a following command to a variable.
ftp myservername
ftp> user
(username) guptaji
331 Password required for guptaji.
Password:
ftp> size /home/salil/abc.dat
ftp> a='size /home/salil/abc.dat'
?Invalid command
I want to redirect value of size to... (1 Reply)
Discussion started by: Salil Gupta
1 Replies
LEARN ABOUT XFREE86
testb
testb(9F) Kernel Functions for Drivers testb(9F)
NAME
testb - check for an available buffer
SYNOPSIS
#include <sys/stream.h>
int testb(size_t size, uint_t pri);
INTERFACE LEVEL
Architecture independent level 1 (DDI/DKI).
PARAMETERS
size Size of the requested buffer.
pri Priority of the allocb request.
DESCRIPTION
testb() checks to see if an allocb(9F) call is likely to succeed if a buffer of size bytes at priority pri is requested. Even if
testb() returns successfully, the call to allocb(9F) can fail. The pri argument is no longer used, but is retained for compatibility.
RETURN VALUES
Returns 1 if a buffer of the requested size is available, and 0 if one is not.
CONTEXT
testb() can be called from user or interrupt context.
EXAMPLES
Example 1: testb() example
In a service routine, if copymsg(9F) fails (line 6), the message is put back on the queue (line 7) and a routine, tryagain, is scheduled
to be run in one tenth of a second. Then the service routine returns.
When the timeout(9F) function runs, if there is no message on the front of the queue, it just returns. Otherwise, for each message block
in the first message, check to see if an allocation would succeed. If the number of message blocks equals the number we can allocate, then
enable the service procedure. Otherwise, reschedule tryagain to run again in another tenth of a second. Note that tryagain is merely an
approximation. Its accounting may be faulty. Consider the case of a message comprised of two 1024-byte message blocks. If there is only
one free 1024-byte message block and no free 2048-byte message blocks, then testb() will still succeed twice. If no message blocks are
freed of these sizes before the service procedure runs again, then the copymsg(9F) will still fail. The reason testb() is used here is
because it is significantly faster than calling copymsg. We must minimize the amount of time spent in a timeout() routine.
1 xxxsrv(q)
2 queue_t *q;
3 {
4 mblk_t *mp;
5 mblk_t *nmp;
. . .
6 if ((nmp = copymsg(mp)) == NULL) {
7 putbq(q, mp);
8 timeout(tryagain, (intptr_t)q, drv_usectohz(100000));
9 return;
10 }
. . .
11 }
12
13 tryagain(q)
14 queue_t *q;
15 {
16 register int can_alloc = 0;
17 register int num_blks = 0;
18 register mblk_t *mp;
19
20 if (!q->q_first)
21 return;
22 for (mp = q->q_first; mp; mp = mp->b_cont) {
23 num_blks++;
24 can_alloc += testb((mp->b_datap->db_lim -
25 mp->b_datap->db_base), BPRI_MED);
26 }
27 if (num_blks == can_alloc)
28 qenable(q);
29 else
30 timeout(tryagain, (intptr_t)q, drv_usectohz(100000));
31 }
SEE ALSO
allocb(9F), bufcall(9F), copymsg(9F), timeout(9F)
Writing Device Drivers
STREAMS Programming Guide
NOTES
The pri argument is provided for compatibility only. Its value is ignored.
SunOS 5.10 11 Nov 1996 testb(9F)