eof

python pexpect & pxssh with sudo and EOF

萝らか妹 提交于 2019-12-23 05:11:42
问题 I make ssh login with this script: import pxssh import pexpect s = pxssh.pxssh() hostname = 'localhost' username = 'py_worker' password = 'nicejob' s.login (hostname, username, password) print "logged in" Then I want to run some program which in some case may require sudo password and in some case may not require. So I want a scrip which could provide sudo password in those cases when required and just run the program if sudo is not asked. I thought this code could handle: s.sendline('sudo

C++ istream EOF does not guarantee failbit?

拜拜、爱过 提交于 2019-12-23 05:08:44
问题 I read a question on Stack Overflow where the eofbit for the istream file is set but the failbit is not. In that case file is true and file.eof() is true but file.good() is false. For example with a file exactly one byte in size: ifstream file("one.txt"); assert( file.is_open() ); for( int i = 0; i < 2; ++i ) { char chars[255] = {0}; file.getline(chars, 2); //file.read( chars, 2 ); cout << "file: " << !!file << endl; cout << "good: " << file.good() << endl; cout << "eof: " << file.eof() <<

Send EOF (^D) to emacs ansi-term

会有一股神秘感。 提交于 2019-12-23 04:34:37
问题 When I use ansi-term mode in Emacs, and run a program such as cat , ^D does not end the input like it normally does. If fact, it doesn't seem to do anything at all. ^C still works. I have Evil installed 回答1: Try adding these to your config (after you load evil): (delete 'term-mode evil-insert-state-modes) (add-to-list 'evil-emacs-state-modes 'term-mode) On my emacs with this modification, cat followed by ^D in ansi-term char-mode ends the input and bring me back to the prompt. Make sure you

Send EOF (^D) to emacs ansi-term

巧了我就是萌 提交于 2019-12-23 04:34:17
问题 When I use ansi-term mode in Emacs, and run a program such as cat , ^D does not end the input like it normally does. If fact, it doesn't seem to do anything at all. ^C still works. I have Evil installed 回答1: Try adding these to your config (after you load evil): (delete 'term-mode evil-insert-state-modes) (add-to-list 'evil-emacs-state-modes 'term-mode) On my emacs with this modification, cat followed by ^D in ansi-term char-mode ends the input and bring me back to the prompt. Make sure you

Detect end of text file, reading using fgetc

给你一囗甜甜゛ 提交于 2019-12-23 02:24:07
问题 I have a text file. I am writing a program to read from the file using fgetc and put in a two dimensional buffer. After printing the contents of file, it's printing some junk until end of buffer despite having put the check for EOF and ERROR as shown below. How can I get it done? unsigned char ch; while(ch=fgetc(fp)) { if(ch== EOF || ch==NULL) break; //OTHER INSTRUCTIONS } Thanks :) 回答1: EOF is an Integer with the value -1 . When you do ch=fgetc(fp) in the while loop, you read into an

EOF, looping forever when the last line is read. c++

南楼画角 提交于 2019-12-23 01:02:52
问题 void ReadTheData(ifstream& in_stream, ofstream& out_stream) { using namespace std; int id; char name[100] = ""; double balance; in_stream >> id >> name >> balance; while(name[0] || ! in_stream.eof()) // Continue looping until eof or name is not present. { cout << id << '\t' << name << '\t' << balance << endl; in_stream >> id >> name >> balance; } } the Balance.txt has format style: 4248749 Kelly_E 460.02 8898693 Kelly_George_MD 1764.68 4597789 Lambert_Richard 1571.79 When I run the code, the

“EOFError: Ran out of input” Keep getting this error while trying to pickle

≡放荡痞女 提交于 2019-12-22 17:04:49
问题 I am writing a quiz program. I am trying to give the user the opportunity to write and add their own question. I have wrote functions to ask and add questions. I am trying to pickle the list of questions so I can auto load new questions anytime somebody adds one. This is the code I am using to load the pickled file. sciIn = open('sciList.txt','rb') sci = pickle.load(sciIn) sciIn.close() I have this code in the function that adds questions. sciOut = open("sciList.txt",'wb') sci.append(dicQ)

Why do i have to input EOF 3 times when using fgets?

喜夏-厌秋 提交于 2019-12-21 21:37:02
问题 So basically I want to copy everything i write to stdin (including newline char) to string for hash purposes. I managed to accomplish that and made small code to represent my problem. #include <stdio.h> #include <string.h> #include <stdlib.h> #define BUFFERSIZE 10000 int main() { char *myStr = calloc(1,1); char buffer[BUFFERSIZE]; while( fgets(buffer, BUFFERSIZE , stdin) != NULL ){ myStr = realloc(myStr, strlen(myStr)+1+strlen(buffer) ); strcat( myStr, buffer ); } printf("\n%s\n",myStr); }

bash EOF in if statement

这一生的挚爱 提交于 2019-12-21 20:14:21
问题 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

Common misconception : Files have an EOF char at their end

纵然是瞬间 提交于 2019-12-21 05:56:10
问题 I was reading "PC assembly language by Carter" and I saw this phrase in footnote of page 32 which made me so confused ! If we assume that files may have not EOF at their end (as the book says) is a correct statement, then how can we figure out where is end of a file ? and it also arises another question : does fseek use EOF to go back and forth in file ? 回答1: PC => ^Z : EOF in the olde PC-days the ctrl-Z was the signal in a file for EOF. under UNIX and other modern systems: after reading