Sponsored Content
Full Discussion: ascii for EOF ???
Top Forums UNIX for Dummies Questions & Answers ascii for EOF ??? Post 17527 by Perderabo on Saturday 16th of March 2002 08:33:32 PM
Old 03-16-2002
Of the two sites that thehoghunter found, I really prefer the first one. That "026 (eof)" is a little misleading. The 26 is a decimal number despite that leading zero. I'm gonna bookmark that first one though....it's awesome.

We need to know the context of the question in order to provide a meaningful answer. You can put any of the 128 ascii characters into a disk file and then read them back. And for that matter all 256 values for a byte can be stored into a file. None of them will cause an "end of file" upon reading. This is why getchar() returns an integer rather than a byte. When it hits end of file, it returns -1.

This is a Unix site and about the only time that Unix is going to let an ascii character represent an "end of file" condition is in the context of terminal driver. You can type "stty -a" to see which character your terminal driver is currently using for end-of-file. And it's configurable...you could change it to any character you want. But the conventional choice is "control-D", aka 004, aka eot (end of transmit).
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

EOF use

Hi, I'd like to access a windows directory from aix with samba client. To allow direct access (not interactive), i'm using EOF like: smbclient \\\\winserver\\windir 'passwd' -U usersmb << EOF cd subwindir put myfile EOF The access is correct but does somebody know how to trap errors... (1 Reply)
Discussion started by: jo_aze
1 Replies

2. UNIX for Dummies Questions & Answers

Eof

hello all, how end of a file is detected in UNIX system? does it make use of any special symbols to identify the EOF? :( thank you all (5 Replies)
Discussion started by: compbug
5 Replies

3. UNIX for Dummies Questions & Answers

Eof

I have written this code: code echo 'Now choose the file or files you want to merge your input with: \c' read filenames filelist="" for file in $filenames; do filelist="$filelist $file" done echo "Now that you've chosen these files ($filelist), please start typing: " until ; do paste -... (2 Replies)
Discussion started by: fiol73
2 Replies

4. Shell Programming and Scripting

Eof

hi, in a shell script i came accross the following bit of code 1.shift $(($OPTIND - 1)) 2.if ; then 3. cat << EOF >&2 4.Usage: $0 lockfilename 5.EOF 6. exit 1 7.fi I am not able to understand the meaning of lines(1,3,5). Can any one of u tell me the purpose of above said lines.... (1 Reply)
Discussion started by: ravi raj kumar
1 Replies

5. Shell Programming and Scripting

What is << EOF

I'm trying to connect to oracle with the following code in the script: checksqlerror{ if echo $1 exit fi } $SQLPLUS username/password@schemaname checksqlerror "failed to connect to oracle" If I'm passing wrong schema name,instead of executing checksqlerror it stops and expects user... (2 Replies)
Discussion started by: BhawanaAggarwal
2 Replies

6. Programming

Eof

How can I write EOF into a file? I tryed to do as follows: size=sizeof(EOF); end_of_file=EOF; write(fdMutexRichieste, &end_of_file, size); But it does non work correctly, becouse in the next cicle (using lseek(..., SEEK_END) of my code it seems to ignore my EOF and use the LAST... (5 Replies)
Discussion started by: DNAx86
5 Replies

7. Shell Programming and Scripting

Until eof do????

Hey! Can I write a routine that allows me to in a txt file check line by line until the end of file? something like until do ---some code--- done maybe it is a stupid question but I never learned shell scripts and I need this :p thanks in advance (1 Reply)
Discussion started by: ruben.rodrigues
1 Replies

8. Shell Programming and Scripting

convert ascii values into ascii characters

Hi gurus, I have a file in unix with ascii values. I need to convert all the ascii values in the file to ascii characters. File contains nearly 20000 records with ascii values. (10 Replies)
Discussion started by: sandeeppvk
10 Replies

9. Shell Programming and Scripting

confused with << EOF EOF

Hi friends , I am confused with << EOF EOF Most of the cases I found sqlplus $db_conn_str << EOF some sql staments EOF another exapmle is #!/bin/sh echo -n 'what is the value? ' read value sed 's/XXX/'$value'/' <<EOF The value is XXX EOF (1 Reply)
Discussion started by: imipsita.rath
1 Replies

10. Shell Programming and Scripting

Convert Hex to Ascii in a Ascii file

Hi All, I have an ascii file in which few columns are having hex values which i need to convert into ascii. Kindly suggest me what command can be used in unix shell scripting? Thanks in Advance (2 Replies)
Discussion started by: HemaV
2 Replies
GETC(3) 						   BSD Library Functions Manual 						   GETC(3)

NAME
fgetc, getc, getc_unlocked, getchar, getchar_unlocked, getw -- get next character or word from input stream LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <stdio.h> int fgetc(FILE *stream); int getc(FILE *stream); int getc_unlocked(FILE *stream); int getchar(void); int getchar_unlocked(void); int getw(FILE *stream); DESCRIPTION
The fgetc() function obtains the next input character (if present) from the stream pointed at by stream, or the next character pushed back on the stream via ungetc(3). The getc() function acts essentially identically to fgetc(), but is a macro that expands in-line. The getchar() function is equivalent to getc(stdin). The getw() function obtains the next int (if present) from the stream pointed at by stream. The getc_unlocked() and getchar_unlocked() functions are equivalent to getc() and getchar() respectively, except that the caller is responsi- ble for locking the stream with flockfile(3) before calling them. These functions may be used to avoid the overhead of locking the stream for each character, and to avoid input being dispersed among multiple threads reading from the same stream. RETURN VALUES
If successful, these routines return the next requested object from the stream. Character values are returned as an unsigned char converted to an int. If the stream is at end-of-file or a read error occurs, the routines return EOF. The routines feof(3) and ferror(3) must be used to distinguish between end-of-file and error. If an error occurs, the global variable errno is set to indicate the error. The end-of-file condition is remembered, even on a terminal, and all subsequent attempts to read will return EOF until the condition is cleared with clearerr(3). SEE ALSO
ferror(3), flockfile(3), fopen(3), fread(3), getwc(3), putc(3), ungetc(3) STANDARDS
The fgetc(), getc(), and getchar() functions conform to ISO/IEC 9899:1990 (``ISO C90''). The getc_unlocked() and getchar_unlocked() func- tions conform to IEEE Std 1003.1-2001 (``POSIX.1''). BUGS
Since EOF is a valid integer value, feof(3) and ferror(3) must be used to check for failure after calling getw(). The size and byte order of an int varies from one machine to another, and getw() is not recommended for portable applications. BSD
January 10, 2003 BSD
All times are GMT -4. The time now is 10:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy