here 'n' is the default value.that means if the user press ENTER key then it should be 'n' .
No
Quote:
Originally Posted by sars
Now how do i know that the user has pressed ENTER key.What will be stored in my variable 'ans'.
ans will contain what you typed until the enter key was pressed. If you only press enter, then that variable will be empty.
To do what you want, you need to do something like:
without pressing the enter key ..manually...
how can we read the enter key ..from the shell script..so that the script termintes automatically.
eg:
telnet a.b.c.d xxxx
now " how to read the enter key" tho terminate the script (1 Reply)
Hello All,
i have a script to get input from the user like bellow,
read -p "Do you want to continue (y/n) : " status
i want to identify the pressing of Enter Key with out giving any value for the above statement and i want get the status if we press Enter key during run time.
How to... (0 Replies)
i have script like:
echo "enter name"
read a
I do not want to press enter key
i have tried with ascill of enter as (\013) but still it wait for enter ,
please resolve my problem (2 Replies)
Hi,
When I run script on Sun Solaris (sassetup), it prompts to "Press Enter To Continue".
Now I want to automate this, ie put sassetup in a script file. So, when I run this file, it should be executed automatically without waiting for anyone to press Enter Key.
I have tried the following... (1 Reply)
My problem is that i have to connect Linux server. I can connect it with SSH but because of the software of the Linux server, i need to press enter and after ctrl+D. Therefore, I need to write a script that should press enter and ctrl+D. How can i write it in KSH shell script. HELP ME! (7 Replies)
Hi Experts,
I have a script in which I want to disable the "Enter" key press. Actually my script executes some process in background. So, till that background process is running, I don't want "Enter" key to be pressed by user. Is this can be achieved using trap command? (6 Replies)
I'm working in a UNIX box that's owned by a vendor. They have it set up by State, meaning when I need to program script related to certain States, I type in, for example, "CA", it goes to a whole other terminal:
ddqsw:pts/2:login
miller CA
TERM = ( vt100 )
When I do this I have to hit... (7 Replies)
I have a popup window that appears on every boot up.
I would like to have it dismissed automatically each time instead of having to hit the enter key.
I thought I could write a script that would execute on startup.
I tried this
xdotool key return
andy@7_~/Downloads$ xdotool key ... (7 Replies)
Discussion started by: drew77
7 Replies
LEARN ABOUT REDHAT
hdestroy
HSEARCH(3) Linux Programmer's Manual HSEARCH(3)NAME
hcreate, hdestroy, hsearch - hash table management
SYNOPSIS
#include <search.h>
int hcreate(size_t nel);
ENTRY *hsearch(ENTRY item, ACTION action);
void hdestroy(void);
#define _GNU_SOURCE
#include <search.h>
int hcreate_r(size_t nel, struct hsearch_data *tab);
int *hsearch_r(ENTRY item, ACTION action, ENTRY **ret, struct hsearch_data *tab);
void hdestroy_r(struct hsearch_data *tab);
DESCRIPTION
The three functions hcreate, hsearch, and hdestroy allow the user to create a hash table (only one at a time) which associates a key with
any data. The three functions hcreate_r, hsearch_r, hdestroy_r are reentrant versions that allow the use of more than one table.
First the table must be created with the function hcreate(). The argument nel is an estimate of the maximum number of entries in the ta-
ble. The function hcreate() may adjust this value upward to improve the performance of the resulting hash table.
The corresponding function hdestroy() frees the memory occupied by the hash table so that a new table can be constructed.
The argument item is of type ENTRY, which is a typedef defined in <search.h> and includes these elements:
typedef struct entry {
char *key;
void *data;
} ENTRY;
The field key points to the NUL-terminated string which is the search key. The field data points to the data associated with that key.
The function hsearch() searches the hash table for an item with the same key as item (where "the same" is determined using strcmp(3)), and
if successful returns a pointer to it. The argument action determines what hsearch() does after an unsuccessful search. A value of ENTER
instructs it to insert a copy of item, while a value of FIND means to return NULL.
RETURN VALUE
hcreate() and hcreate_r() return 0 when allocation of the memory for the hash table fails, nonzero otherwise.
hsearch() returns NULL if action is ENTER and the hash table is full, or action is FIND and item cannot be found in the hash table.
hsearch_r() returns 0 if action is ENTER and the hash table is full, and nonzero otherwise.
ERRORS
ENOMEM Out of memory.
CONFORMS TO
The functions hcreate, hsearch, and hdestroy are from SVID, and are described in POSIX 1003.1-2001. The functions hcreate_r, hsearch_r,
hdestroy_r are GNU extensions.
BUGS
SVID and POSIX 1003.1-2001 specify that action is significant only for unsuccessful searches, so that an ENTER should not do anything for a
successful search. The libc and glibc implementations update the data for the given key in this case.
Individual hash table entries can be added, but not deleted.
EXAMPLE
The following program inserts 24 items in to a hash table, then prints some of them.
#include <stdio.h>
#include <search.h>
char *data[] = { "alpha", "bravo", "charlie", "delta",
"echo", "foxtrot", "golf", "hotel", "india", "juliet",
"kilo", "lima", "mike", "november", "oscar", "papa",
"quebec", "romeo", "sierra", "tango", "uniform",
"victor", "whisky", "x-ray", "yankee", "zulu"
};
int main() {
ENTRY e, *ep;
int i;
/* starting with small table, and letting it grow does not work */
hcreate(30);
for (i = 0; i < 24; i++) {
e.key = data[i];
/* data is just an integer, instead of a
pointer to something */
e.data = (char *)i;
ep = hsearch(e, ENTER);
/* there should be no failures */
if (ep == NULL) {
fprintf(stderr, "entry failed
");
exit(1);
}
}
for (i = 22; i < 26; i++) {
/* print two entries from the table, and
show that two are not in the table */
e.key = data[i];
ep = hsearch(e, FIND);
printf("%9.9s -> %9.9s:%d
", e.key,
ep ? ep->key : "NULL",
ep ? (int)(ep->data) : 0);
}
return 0;
}
SEE ALSO bsearch(3), lsearch(3), tsearch(3), malloc(3)GNU 2001-12-26 HSEARCH(3)