Sponsored Content
Top Forums Programming Number of bytes in terminal input queue w/o blocking and consuming? Post 302282240 by fpmurphy on Friday 30th of January 2009 11:06:43 AM
Old 01-30-2009
There is no standard API for returning this information. You need to use the FIONREAD ioctl if it is available on your platform. Typical code would be something like the following.
Code:
  #include <sys/ioctl.h>

  int chars_avail;
  int result;

  result = ioctl (tty, FIONREAD, &chars_avail);

 

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
IPL(4)							     Kernel Interfaces Manual							    IPL(4)

NAME
ipl - IP packet log device DESCRIPTION
The ipl pseudo device's purpose is to provide an easy way to gather packet headers of packets you wish to log. If a packet header is to be logged, the entire header is logged (including any IP options - TCP/UDP options are not included when it calculates header size) or not at all. The packet contents are also logged after the header. If the log reader is busy or otherwise unable to read log records, up to IPLLOGSIZE (8192 is the default) bytes of data are stored. Prepending every packet header logged is a structure containing information relevant to the packet following and why it was logged. The structure's format is as follows: /* * Log structure. Each packet header logged is prepended by one of these. * Following this in the log records read from the device will be an ipflog * structure which is then followed by any packet data. */ typedef struct iplog { u_long ipl_sec; u_long ipl_usec; u_int ipl_len; u_int ipl_count; size_t ipl_dsize; struct iplog *ipl_next; } iplog_t; typedef struct ipflog { #if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) u_char fl_ifname[IFNAMSIZ]; #else u_int fl_unit; u_char fl_ifname[4]; #endif u_char fl_plen; /* extra data after hlen */ u_char fl_hlen; /* length of IP headers saved */ u_short fl_rule; /* assume never more than 64k rules, total */ u_32_t fl_flags; } ipflog_t; When reading from the ipl device, it is necessary to call read(2) with a buffer big enough to hold at least 1 complete log record - reading of partial log records is not supported. If the packet contents are more than 128 bytes when log body is used, then only 128 bytes of the packet contents are logged. Although it is only possible to read from the ipl device, opening it for writing is required when using an ioctl which changes any kernel data. The ioctls which are loaded with this device can be found under ipf(4). The ioctls which are for use with logging and don't affect the filter are: ioctl(fd, SIOCIPFFB, int *) ioctl(fd, FIONREAD, int *) The SIOCIPFFB ioctl flushes the log buffer and returns the number of bytes flushed. FIONREAD returns the number of bytes currently used for storing log data. If IPFILTER_LOG is not defined when compiling, SIOCIPFFB is not available and FIONREAD will return but not do any- thing. There is currently no support for non-blocking IO with this device, meaning all read operations should be considered blocking in nature (if there is no data to read, it will sleep until some is made available). SEE ALSO
ipf(4) BUGS
Packet headers are dropped when the internal buffer (static size) fills. FILES
/dev/ipl IPL(4)
All times are GMT -4. The time now is 10:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy