Sponsored Content
Full Discussion: ksh read timeout
Top Forums Shell Programming and Scripting ksh read timeout Post 92331 by ashterix on Friday 9th of December 2005 11:08:58 AM
Old 12-09-2005
ksh read timeout

any idea on how to timeout the read statement for ksh?

for bash u can use read -t option
-t timeout
Cause read to time out and return failure if a complete
line of input is not read within timeout seconds. This
option has no effect if read is not reading input from
the terminal or a pipe.

thanks in advance!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Giving "read" from standard input a timeout.

I want to prompt a user for input but I want it to timeout after a specified time if no response is given. I tried the sleep command but this does not work. I am using ksh. Thanks. (10 Replies)
Discussion started by: rello
10 Replies

2. Shell Programming and Scripting

is there any way to read a line twice in KSH

Hi All, Is there any way to read the previous line in file reading ? or is there any way to read a line twice in KSH ? thanks in advance !! Srini (6 Replies)
Discussion started by: Srini75
6 Replies

3. Shell Programming and Scripting

How to timeout the "read" command

I have a script that at some point will ask the interactive user a question: #!/bin/ksh echo "What is your access code?" read ans ... Sometimes this script is run by other scripts and there are no interactive users. The script then hangs on the "read" command, waiting for a user response... (5 Replies)
Discussion started by: rm-r
5 Replies

4. Shell Programming and Scripting

read from std i/p with timeout within a script

hello every one , this is my first participation in the forum , I hope it'll be a good start within a script I would like to put some code to read i\p from standard i\p using read command if it reads Y it will terminate the script if it reads N it will continue execution , if no i\p is... (2 Replies)
Discussion started by: Blue_shadow
2 Replies

5. Shell Programming and Scripting

KSH script SQL timeout issue

Hi all, I have a KSH script which is kicking off an sql scripts as follows: /usr/local/installs/instantclient_10_2/sqlplus -s username/password @$sql_path/sql_query.sql > $tmp_path/sql_query_results The problem I have is that sometimes the 10g Oracle Database spits out an error saying... (4 Replies)
Discussion started by: Donkey25
4 Replies

6. Boot Loaders

read sectors from disk failed with timeout

i'm writing some code to simulate the boot progress after power on but when i try to read the 2nd sector from a floppy disk, this operation always fail with ah=0x80h which means timeout, how can i get over this problem? my code would be like this: $ cat boot.S .code16 #define SETUPLEN 4... (0 Replies)
Discussion started by: wljackhero
0 Replies

7. Linux

read sectors from disk failed with timeout

i'm writing some code to simulate the boot progress after power on but when i try to read the 2nd sector from a floppy disk, this operation always fail with ah=0x80h which means timeout, how can i get over this problem? my code would be like this: $ cat boot.S .code16 #define SETUPLEN 4... (0 Replies)
Discussion started by: wljackhero
0 Replies

8. UNIX for Advanced & Expert Users

read sectors from disk failed with timeout

i'm writing some code to simulate the boot progress after power on but when i try to read the 2nd sector from a floppy disk, this operation always fail with ah=0x80h which means timeout, how can i get over this problem? my code would be like this: $ cat boot.S .code16 #define SETUPLEN 4... (0 Replies)
Discussion started by: wljackhero
0 Replies

9. 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

10. Shell Programming and Scripting

Read timeout

I saw several thread for this issue but none addresses my issue. I have tried read -t but the result is read bad options My requirement is 1. Ask for input 2. If input = y or no input in 60 seconds then continue processing else exit fi Kindly consider this urgent. (8 Replies)
Discussion started by: rprasad
8 Replies
STREAM_SELECT(3)							 1							  STREAM_SELECT(3)

stream_select - Runs the equivalent of the select() system call on the given arrays of streams with a timeout specified by tv_sec and tv_usec

SYNOPSIS
int stream_select (array &$read, array &$write, array &$except, int $tv_sec, [int $tv_usec]) DESCRIPTION
The stream_select(3) function accepts arrays of streams and waits for them to change status. Its operation is equivalent to that of the socket_select(3) function except in that it acts on streams. PARAMETERS
o $read - The streams listed in the $read array will be watched to see if characters become available for reading (more precisely, to see if a read will not block - in particular, a stream resource is also ready on end-of-file, in which case an fread(3) will return a zero length string). o $write - The streams listed in the $write array will be watched to see if a write will not block. o $except - The streams listed in the $except array will be watched for high priority exceptional ("out-of-band") data arriving. Note When stream_select(3) returns, the arrays $read, $write and $except are modified to indicate which stream resource(s) actu- ally changed status. You do not need to pass every array to stream_select(3). You can leave it out and use an empty array or NULL instead. Also do not forget that those arrays are passed by reference and will be modified after stream_select(3) returns. o $tv_sec - The $tv_sec and $tv_usec together form the timeout parameter, $tv_sec specifies the number of seconds while $tv_usec the number of microseconds. The $timeout is an upper bound on the amount of time that stream_select(3) will wait before it returns. If $tv_sec and $tv_usec are both set to 0, stream_select(3) will not wait for data - instead it will return immediately, indicating the current status of the streams. If $tv_sec is NULLstream_select(3) can block indefinitely, returning only when an event on one of the watched streams occurs (or if a signal interrupts the system call). Warning Using a timeout value of 0 allows you to instantaneously poll the status of the streams, however, it is NOT a good idea to use a 0 timeout value in a loop as it will cause your script to consume too much CPU time. It is much better to specify a timeout value of a few seconds, although if you need to be checking and running other code concurrently, using a timeout value of at least 200000 microseconds will help reduce the CPU usage of your script. Remember that the timeout value is the maximum time that will elapse; stream_select(3) will return as soon as the requested streams are ready for use. o $tv_usec - See $tv_sec description. RETURN VALUES
On success stream_select(3) returns the number of stream resources contained in the modified arrays, which may be zero if the timeout expires before anything interesting happens. On error FALSE is returned and a warning raised (this can happen if the system call is inter- rupted by an incoming signal). EXAMPLES
Example #1 stream_select(3) Example This example checks to see if data has arrived for reading on either $stream1 or $stream2. Since the timeout value is 0 it will return immediately: <?php /* Prepare the read array */ $read = array($stream1, $stream2); $write = NULL; $except = NULL; if (false === ($num_changed_streams = stream_select($read, $write, $except, 0))) { /* Error handling */ } elseif ($num_changed_streams > 0) { /* At least on one of the streams something interesting happened */ } ?> NOTES
Note Due to a limitation in the current Zend Engine it is not possible to pass a constant modifier like NULL directly as a parameter to a function which expects this parameter to be passed by reference. Instead use a temporary variable or an expression with the left- most member being a temporary variable: <?php $e = NULL; stream_select($r, $w, $e, 0); ?> Note Be sure to use the === operator when checking for an error. Since the stream_select(3) may return 0 the comparison with == would evaluate to TRUE: <?php $e = NULL; if (false === stream_select($r, $w, $e, 0)) { echo "stream_select() failed "; } ?> Note If you read/write to a stream returned in the arrays be aware that they do not necessarily read/write the full amount of data you have requested. Be prepared to even only be able to read/write a single byte. Note Some streams (like zlib) cannot be selected by this function. Note Windows compatibility: stream_select(3) used on a pipe returned from proc_open(3) may cause data loss under Windows 98. Use of stream_select(3) on file descriptors returned by proc_open(3) will fail and return FALSE under Windows. SEE ALSO
stream_set_blocking(3). PHP Documentation Group STREAM_SELECT(3)
All times are GMT -4. The time now is 07:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy