eof

sys.stdin does not close on ctrl-d

耗尽温柔 提交于 2019-12-04 14:03:40
问题 I have the following code in program.py: from sys import stdin for line in stdin: print line I run, enter lines, and then press Ctrl + D , but the program does not exit. This does work: $ printf "echo" | python program.py Why does the program not exit when I press Ctrl + d ? I am using the Fedora 18 terminal. 回答1: Ctrl + D has a strange effect. It doesn't close the input stream, but only causes a C-level fread() to return an empty result. For regular files such a result means that the file is

bash EOF in if statement

隐身守侯 提交于 2019-12-04 12:18:12
I am trying to do an action in a IF ELSE statement in Bash, but receive an error like this one: Syntax error: end of file unexpected (expecting "fi") Now I am quite new to this, so probably the solution to my problem should not be that difficult :) if [ "$DAYNAME" = 'Sunday' ]; then echo 'The backup will be uploaded' ftp -n $HOST <<EOF quote USER $USER quote PASS $PASSWD put $filetoday delete ${filethreeweeksago} quit EOF fi Of course the vars are already filled. I think it has to do with the EOF notation, because when i remove them, the problem disapears. Unfortunatly I don't know how to use

what does rdstate() return value means?

孤街醉人 提交于 2019-12-04 12:12:15
问题 istream& Read(istream &is) { std::string buf; while (is >> buf) { cout << is.eofbit << " " << is.failbit << " " << is.badbit << endl; cout << is.rdstate() << endl; cout << buf << endl; } cout << is.eofbit << " " << is.failbit << " " << is.badbit << endl; cout << is.rdstate() << endl; is.clear(); cout << is.eofbit << " " << is.failbit << " " << is.badbit << endl; cout << is.rdstate() << endl; return is; } If I input normal characters like "test",the output is 1 2 4 0 . Then I type CTRL+Z

Erlang: How to pipe stdin input from a file to an erlang program and match eof?

南笙酒味 提交于 2019-12-04 11:48:23
How to pipe input from a file as stdin to an erlang program running in the shell as well as standalone? I have a file hr.erl and I compile it from the shell. There is a function in it which accepts input from stdin using io:fread() . I have written a case expression with guards where if it matches {ok, [0]} it should terminate. Instead of 0 , I actually need it to be eof . How to send eof when running in a shell? I have a file inp.txt with values 1 2 3 and 0 on each line. How can I pass it using the < pipe operator? Is there anything like erl -hr <inp.txt ? Can I pipe it to stdin within the

EOF Error in Imaplib

浪尽此生 提交于 2019-12-04 11:07:58
问题 I am programming a python applet that watches the unread count of the email boxes for my workplace, and ran into an EOF error when I try to use any imaplib methods after the applet sits idle for about 10 minutes. Everything works fine until the applet has been alive for more than 10 minutes. Here is the relevant code for the imaplib object. conn = imaplib.IMAP4_SSL("imap.gmail.com", 993) def loginIMAP (imapObj): # Login to Helpdesk Google Apps Email account using encryption imapObj.login

What is the meaning of EOF exceptions in hadoop namenode connections from hbase/filesystem?

≯℡__Kan透↙ 提交于 2019-12-04 10:56:36
问题 This is both a general question about java EOF exceptions, as well as Hadoop's EOF exception which is related to jar interoperability. Comments and answers on either topic are acceptable. Background I'm noting some threads which discuss a cryptic exception, which is ultimately caused by a "readInt" method. This exception seems to have some generic implications which are independent of hadoop, but ultimately, is caused by interoperability of Hadoop jars. In my case, I'm getting it when I try

EOF symbolic constant

早过忘川 提交于 2019-12-04 06:41:02
From The C Programming Language : int c; while ((c = getchar()) != EOF) putchar(c); "... The solution is that getchar returns a distinctive value when there is no more input, a value that cannot be confused with any real character. This value is called EOF , for "end of file." We must declare c to be a type big enough to hold any value that getchar returns. We can't use char since c must be big enough to hold EOF in addition to any possible char ." I checked in stdio.h and printed the value of EOF on my system, and it's set to -1 . On my system, chars are signed, although I understand that

read data from file till end of line in C/C++

自古美人都是妖i 提交于 2019-12-04 05:48:30
It is common to read until end of file, but I am interested in how could I read data (a series of numbers) from a text file until the end of a line ? I got the task to read several series of numbers from a file, which are positioned in new lines. Here is an example of input: 1 2 53 7 27 8 67 5 2 1 56 9 100 2 3 13 101 78 First series: 1 2 53 7 27 8 Second one: 67 5 2 Third one: 1 56 9 100 2 3 13 101 78 I have to read them separately from file, but each one till the end of line. I have this code: #include <stdio.h> FILE *fp; const char EOL = '\\0'; void main() { fp = fopen("26.txt", "r"); char

C EOF symbolic value and signed character

被刻印的时光 ゝ 提交于 2019-12-04 05:10:41
问题 today i just lay on my bed meditating programming stuff when an idea flows into my mind which i can't solve with my own ability.Below is the Question. I read a book that explain why EOF value is -1 and the explanation is as follow : Why -1?Normally getchar() returns a value in the range 0 through 127 , because those are values corresponding to the standard character set , but it might return values from 0 through 255 if the system recognizes an extended character set . In either case , the

How do I distinguish between an EOF character, and the actual end of file?

南楼画角 提交于 2019-12-04 01:32:37
问题 When reading a file, I understand the last character provided is an EOF . Now, what happens, when I have an EOF character in that file? How do I distinguish between the "real" end of a file, and the EOF character? 回答1: I decided to move my comments to an answer. You can't have an "EOF character" in your file because there is no such thing. The underlying filesystem knows how many bytes are in a file; it doesn't rely on the contents of the file to know where the end is. The C functions you're