Sponsored Content
Top Forums Programming How i can read a long integer from standar input and a string with as many characters as specified.. Post 302362300 by aintour on Thursday 15th of October 2009 02:07:57 PM
Old 10-15-2009
its not an assignment, its for an exercise....but i dont know how to do it with read
its something like this. read (STDIN, BUFFER, SIZE)

but the i dont know how to continue, ok


printf("GIVE NUMBER");
i = read (STDIN, BUFFER, SIZE);

with pointers after or whatever...

something like this....
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Check if input is an integer or a floating point?

Hiii I actually intent to check the integer or floating point number input by user i.e. 23, 100, 55.25, 12.50 ..etc. However, when someone input strings or alpha character, my program has to show invalid input.!! Is there any Unix shell script syntax can help me to check ? Thanking you (2 Replies)
Discussion started by: krishnampkkm
2 Replies

2. Shell Programming and Scripting

Using IF statements with maths where the input is not an integer

Hi All I've made a few scripts which using GDAL extract the value of a pixel within a given raster. The purpose is to work out the combine value of every pixel. I thought there may have been an easier way to do this but alas! The code below extracts the pixel value at position X Y. The... (3 Replies)
Discussion started by: StudentFitz
3 Replies

3. Shell Programming and Scripting

Take input from read and place it a string in another file

Hi, This is most likely a dumb question but I could not find answer to it elsewhere. I'm building a simple menu with case /esac and want to read user's input: Please enter XYZ ; read XYZ How do I take the value of XYZ and insert it as a variable $XYZ in file file.txt ? I may need to... (9 Replies)
Discussion started by: svetoslav_sj
9 Replies

4. Shell Programming and Scripting

how to compare string integer with an integer?

hi, how to I do this? i="4.000" if ; then echo "smaller" fi how do I convert the "4.000" to 4? Thanks! (4 Replies)
Discussion started by: h0ujun
4 Replies

5. Shell Programming and Scripting

Read input and match string

#!/bin/ksh echo DB LIST ps -ef | grep pmon | grep -v grep | awk -F_ '{print $3}' | sort db_up=`ps -ef | grep pmon | grep -v grep | awk -F_ '{print $3}' | sort` echo echo "Enter database name from the above list" echo read ORACLE_SID echo echo Database selected is: $ORACLE_SID echo ... (10 Replies)
Discussion started by: crazy_max
10 Replies

6. Shell Programming and Scripting

How to read from file and convert from string to integer?

Hi all, I am trying to write a script to be able to Run top command Pick the PIDs that are taking more than 90% of CPU time Get more details like what is the script name and location for that PID Script should run until I manually kill it by ctrl + C I have come up with following script... (3 Replies)
Discussion started by: pat_pramod
3 Replies

7. Shell Programming and Scripting

How to avoid "Too many arguments" error, when passing a long String literal as input to a command?

Hi, I am using awk here. Inside an awk script, I have a variable which contains a very long XML data in string format (500kb). I want to pass this data (as argument) to curl command using system function. But getting Too many arguments error due to length of string data(payloadBlock). I... (4 Replies)
Discussion started by: cool.aquarian
4 Replies

8. Shell Programming and Scripting

Use while loop to read file and use ${file} for both filename input into awk and as string to print

I have files named with different prefixes. From each I want to extract the first line containing a specific string, and then print that line along with the prefix. I've tried to do this with a while loop, but instead of printing the prefix I print the first line of the file twice. Files:... (3 Replies)
Discussion started by: pathunkathunk
3 Replies

9. Shell Programming and Scripting

Printf or any other method to put long string of spec characters - passing passwords

Hello, I am looking for a method to use in my bash script which allows me to use long strings with all special characters. I have found that printf method could be helpful for me but unfortunately, when I trying root@machine:~# tevar=`printf "%s%c"... (2 Replies)
Discussion started by: elxa1
2 Replies

10. UNIX for Beginners Questions & Answers

awk command input string too long, limit

cat filename| awk '{ $1=""; print $0}' in my file there are few lines that has more than 3000 characters per line and as soon as I run the above command it cores, strings core reveals that the awk is failing because input string too long, limit. can i get some help from the experts to find... (8 Replies)
Discussion started by: knijjar
8 Replies
read(n) 						       Tcl Built-In Commands							   read(n)

__________________________________________________________________________________________________________________________________________________

NAME
read - Read from a channel SYNOPSIS
read ?-nonewline? channelId read channelId numChars _________________________________________________________________ DESCRIPTION
In the first form, the read command reads all of the data from channelId up to the end of the file. If the -nonewline switch is specified then the last character of the file is discarded if it is a newline. In the second form, the extra argument specifies how many characters to read. Exactly that many characters will be read and returned, unless there are fewer than numChars left in the file; in this case all the remaining characters are returned. If the channel is configured to use a multi-byte encoding, then the number of characters read may not be the same as the number of bytes read. ChannelId must be an identifier for an open channel such as the Tcl standard input channel (stdin), the return value from an invocation of | open or socket, or the result of a channel creation command provided by a Tcl extension. The channel must have been opened for input. If channelId is in nonblocking mode, the command may not read as many characters as requested: once all available input has been read, the command will return the data that is available rather than blocking for more input. If the channel is configured to use a multi-byte encoding, then there may actually be some bytes remaining in the internal buffers that do not form a complete character. These bytes will not be returned until a complete character is available or end-of-file is reached. The -nonewline switch is ignored if the command returns before reaching the end of the file. Read translates end-of-line sequences in the input into newline characters according to the -translation option for the channel. See the fconfigure manual entry for a discussion on ways in which fconfigure will alter input. USE WITH SERIAL PORTS
For most applications a channel connected to a serial port should be configured to be nonblocking: fconfigure channelId -blocking 0. Then read behaves much like described above. Care must be taken when using read on blocking serial ports: read channelId numChars In this form read blocks until numChars have been received from the serial port. read channelId In this form read blocks until the reception of the end-of-file character, see fconfigure -eofchar. If there no end-of-file charac- ter has been configured for the channel, then read will block forever. SEE ALSO
file(n), eof(n), fblocked(n), fconfigure(n), Tcl_StandardChannels(3) KEYWORDS
blocking, channel, end of line, end of file, nonblocking, read, translation, encoding Tcl 8.1 read(n)
All times are GMT -4. The time now is 06:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy