Sponsored Content
Top Forums Programming Number of bytes in terminal input queue w/o blocking and consuming? Post 302281891 by Lucy.Garfeld on Thursday 29th of January 2009 05:30:14 PM
Old 01-29-2009
Number of bytes in terminal input queue w/o blocking and consuming?

Hello, everyone.

Could someone, please, tell me how to get the number of bytes in the terminal input queue without blocking and without consuming these bytes? I guess it could be called the peek functionality.

I've looked at termio tcgetattr() and tcsetattr() functions but could not find exactly what I need. I know I can poll() on stdin. But I don't want to read after poll() returns. I just want to see how many characters, if any, can be read without blocking from stdin - terminal in my case.

Thanks for any hints.
Lucy.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help on counting number of bytes in a field

Hi, I have a file that has 300 records with a load of fields. two of them are: field_1 has between 8-9 bytes i.e. 012345678, 0123456789 field_2 has 10 bytes i.e. 01234567890 I want to be able to echo out the total of each of these fields i.e. 200 (have 8 - 9 bytes) 100 (have 10 bytes)... (3 Replies)
Discussion started by: Pablo_beezo
3 Replies

2. UNIX for Dummies Questions & Answers

Display just CPU run queue number (Nothing Else)

Im using the vmstat command to display the CPU run queue, but i want to put that into a program so is there a way to just display the number under the r? Thanks, (1 Reply)
Discussion started by: RAFC_99
1 Replies

3. Shell Programming and Scripting

AWK input can not be longer than 3000 bytes

Hi, i have following line in my code. eport.pl < $4 | dos2ux | head -2000 | paste -sd\| - | awk -v S="$1" ' Issue is, i get a message saying "awk:input line | found /file/path cannot be longer than 3000 bytes." "source line number is 3" Can someone help me with this please? (4 Replies)
Discussion started by: usustarr
4 Replies

4. AIX

Maximum number of Print Queue on AIX?

Hi, Currently we are experiencing qdaemon died, hourly. We have more than 10,000 print queue on AIX 5.3. Would this cause the qdaemon to die? What is the maximum number of print queue on AIX 5.3? Thank you in advance. (0 Replies)
Discussion started by: raybakh
0 Replies

5. Shell Programming and Scripting

count of files and number of bytes

1) I need a shell code to count the number of files ( without directories or sub-directories ) in a directory given as arguments I tried this code but it didn't work , maybe I tried the wrong one: numOfFiles=`find $1 -type f -maxdepth 1 | wc -l` I found it in another thread in this site.. ... (17 Replies)
Discussion started by: jack1985
17 Replies

6. Shell Programming and Scripting

awk: Input line Cannot be longer than 3,000 bytes.

Guys, I want to get the high CPU utilization from top. I am using below code : top -d2 >> /home/dba_monitoring/host_top_output.txt echo "Script started `date`" > $runlog usage=`grep "^ *$1" /home/dba_monitoring/host_top_output.txt | awk '{print $12}' | sed 's/%//'` And getting below... (7 Replies)
Discussion started by: wahab
7 Replies

7. Programming

How to get the number of bytes parsed in libxml2

Hi, I am using the libxml2 sax parser to parse a in memory xml string along with validating it against a schema. I am using the following code: xmlSAXHandlerPtr sax_ = new xmlSAXHandler(); sax_->initialized = XML_SAX2_MAGIC; sax_->startElementNs =... (0 Replies)
Discussion started by: Sam Krishna
0 Replies

8. Shell Programming and Scripting

Bash script to find the number of files and identify which ones are 0 bytes.

I am writing a bash script to find out all the files in a directory which are empty. I am running into multiple issues. I will really appreciate if someone can please help me. #!/bin/bash DATE=$(date +%m%d%y) TIME=$(date +%H%M) DIR="/home/statsetl/input/civil/test" ... (1 Reply)
Discussion started by: monasharma13
1 Replies

9. UNIX for Dummies Questions & Answers

X bytes of 0, Y bytes of random data, Z bytes of 5, T bytes of 1. ??

Hello guys. I really hope someone will help me with this one.. So, I have to write this script who: - creates a file home/student/vmdisk of 10 mb - formats that file to ext3 - mounts that partition to /mnt/partition - creates a file /mnt/partition/data. In this file, there will... (1 Reply)
Discussion started by: razolo13
1 Replies

10. Shell Programming and Scripting

Shell script - entered input(1-40 bytes) needs to be converted exactly 40 bytes

hello, suppose, entered input is of 1-40 bytes, i need it to be converted to 40 bytes exactly. example: if i have entered my name anywhere between 1-40 i want it to be stored with 40 bytes exactly. enter your name: donald duck (this is of 11 bytes) expected is as below - display 11... (3 Replies)
Discussion started by: shravan.300
3 Replies
tcsetattr(3C)						   Standard C Library Functions 					     tcsetattr(3C)

NAME
tcsetattr - set the parameters associated with the terminal SYNOPSIS
#include <termios.h> int tcsetattr(int fildes, int optional_actions, const struct termios *termios_p); DESCRIPTION
The tcsetattr() function sets the parameters associated with the terminal referred to by the open file descriptor fildes (an open file descriptor associated with a terminal) from the termios structure (see termio(7I)) referenced by termios_p as follows: o If optional_actions is TCSANOW, the change will occur immediately. o If optional_actions is TCSADRAIN, the change will occur after all output written to fildes is transmitted. This function should be used when changing parameters that affect output. o If optional_actions is TCSAFLUSH, the change will occur after all output written to fildes is transmitted, and all input so far received but not read will be discarded before the change is made. If the output baud rate stored in the termios structure pointed to by termios_p is the zero baud rate, B0, the modem control lines will no longer be asserted. Normally, this will disconnect the line. If the input baud rate stored in the termios structure pointed to by termios_p is 0, the input baud rate given to the hardware will be the same as the output baud rate stored in the termios structure. The tcsetattr() function will return successfully if it was able to perform any of the requested actions, even if some of the requested actions could not be performed. It will set all the attributes that implementation supports as requested and leave all the attributes not supported by the implementation unchanged. If no part of the request can be honoured, it will return -1 and set errno to EINVAL. If the input and output baud rates differ and are a combination that is not supported, neither baud rate is changed. A subsequent call to tcge- tattr(3C) will return the actual state of the terminal device (reflecting both the changes made and not made in the previous tcsetattr() call). The tcsetattr() function will not change the values in the termios structure whether or not it actually accepts them. The effect of tcsetattr() is undefined if the value of the termios structure pointed to by termios_p was not derived from the result of a call to tcgetattr(3C) on fildes; an application should modify only fields and flags defined by this document between the call to tcge- tattr(3C) and tcsetattr(), leaving all other fields and flags unmodified. No actions defined by this document, other than a call to tcsetattr() or a close of the last file descriptor in the system associated with this terminal device, will cause any of the terminal attributes defined by this document to change. Attempts to use tcsetattr() from a process which is a member of a background process group on a fildes associated with its controlling ter- minal, will cause the process group to be sent a SIGTTOU signal. If the calling process is blocking or ignoring SIGTTOU signals, the process is allowed to perform the operation, and no signal is sent. USAGE
If trying to change baud rates, applications should call tcsetattr() then call tcgetattr(3C) in order to determine what baud rates were actually selected. RETURN VALUES
Upon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The tcsetattr() function will fail if: EBADF The fildes argument is not a valid file descriptor. EINTR A signal interrupted tcsettattr(). EINVAL The optional_actions argument is not a supported value, or an attempt was made to change an attribute represented in the termios structure to an unsupported value. ENOTTY The file associated with fildes is not a terminal. The tcsetattr() function may fail if: EIO The process group of the writing process is orphaned, and the writing process is not ignoring or blocking SIGTTOU. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-------------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-------------------------------+ |Interface Stability |Standard | +-----------------------------+-------------------------------+ |MT-Level |MT-Safe, and Async-Signal-Safe | +-----------------------------+-------------------------------+ SEE ALSO
cfgetispeed(3C), tcgetattr(3C), attributes(5), standards(5), termio(7I) SunOS 5.10 14 Aug 2002 tcsetattr(3C)
All times are GMT -4. The time now is 01:34 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy