piping

Python piping on Windows: Why does this not work?

我的未来我决定 提交于 2019-11-27 02:17:10
问题 I'm trying something like this Output.py print "Hello" Input.py greeting = raw_input("Give me the greeting. ") print "The greeting is:", greeting At the cmd line Output.py | Input.py But it returns an EOFError . Can someone tell me what I am doing wrong? Thanks for your help. EDIT Patrick Harrington solution works but I don't know why... 回答1: I tested this on my Windows machine and it works if you specify the Python exe: C:\>C:\Python25\python.exe output.py | C:\Python25\python.exe input.py

CMD: piping ECHO to SET/ expanding variables in variables

自作多情 提交于 2019-11-26 22:12:15
问题 %x:~12,3% Returns 3 characters starting at the 12:th character in x variable. What I have been trying to accomplish is using variables instead of 12 and 3 . Let's say y=12 and z=3 . Then, you can't use %x:~%y%,%z%% , because CMD will think %x:~% is a variable. What you can do is set var=%%x:~%y%,%z%%% . This will expand the inside variables y and z , but not x , so that the value of var is %x:~12,3% . The remaining task at hand now is to finally expand %x:~12,3% . I have been trying to append

putting a remote file into hadoop without copying it to local disk

心不动则不痛 提交于 2019-11-26 18:59:18
问题 I am writing a shell script to put data into hadoop as soon as they are generated. I can ssh to my master node, copy the files to a folder over there and then put them into hadoop. I am looking for a shell command to get rid of copying the file to the local disk on master node. to better explain what I need, here below you can find what I have so far: 1) copy the file to the master node's local disk: scp test.txt username@masternode:/folderName/ I have already setup SSH connection using keys.

Using fseek with a file pointer that points to stdin

萝らか妹 提交于 2019-11-26 12:19:39
问题 Depending on command-line arguments, I\'m setting a file pointer to point either towards a specified file or stdin (for the purpose of piping). I then pass this pointer around to a number of different functions to read from the file. Here is the function for getting the file pointer: FILE *getFile(int argc, char *argv[]) { FILE *myFile = NULL; if (argc == 2) { myFile = fopen(argv[1], \"r\"); if (myFile == NULL) fprintf(stderr, \"File \\\"%s\\\" not found\\n\", argv[1]); } else myFile = stdin;

Making C code plot a graph automatically

∥☆過路亽.° 提交于 2019-11-26 10:34:41
问题 I have written a program which writes a list of data to a \'.dat\' file with the intention of then plotting it separately using gnuplot. Is there a way of making my code plot it automatically? My output is of the form: x-coord analytic approximation x-coord analytic approximation x-coord analytic approximation x-coord analytic approximation x-coord analytic approximation .... Ideally, when I run the code the graph would also be printed with an x-label, y-label and title (which could be