output

use perl to extract specific output lines

浪尽此生 提交于 2019-12-12 03:16:21
问题 I'm endeavoring to create a system to generalize rules from input text. I'm using reVerb to create my initial set of rules. Using the following command[*], for instance: $ echo "Bananas are an excellent source of potassium." | ./reverb -q | tr '\t' '\n' | cat -n To generate output of the form: 1 stdin 2 1 3 Bananas 4 are an excellent source of 5 potassium 6 0 7 1 8 1 9 6 10 6 11 7 12 0.9999999997341693 13 Bananas are an excellent source of potassium . 14 NNS VBP DT JJ NN IN NN . 15 B-NP B-VP

Why is my code to enter input to a batch file not working?

情到浓时终转凉″ 提交于 2019-12-12 03:14:00
问题 I'm trying to write to a loaded batch file process, but I cannot figure out how to do the equivalent of a return. Java Code: import java.io.DataInputStream; import java.io.DataOutputStream; import java.util.Scanner; public class Start { public static void main(String[] args) { try { Process p = Runtime.getRuntime().exec("C:\\Users\\Max\\Desktop\\test.bat");// Runtime.getRuntime().exec("keytool -genkey -alias " + name.replace(" ", "").trim() + " -keystore key"); DataInputStream in = new

Input only to bottom line of terminal

倖福魔咒の 提交于 2019-12-12 03:13:09
问题 I made a command-line chat client with Java, that sends the messages from stdin to the server and, at the same time, receives messages from the server to stdout at the same time. It's likely that somebody may send a message while you're writing one, so I want the bottom line of the terminal always reserved for input, so that output appears above it. I hope you understand my question and I apologize in advance if you don't. 回答1: The JCurses library will do exactly what you need. http:/

redirecting the output of shell command to &- what does it mean

会有一股神秘感。 提交于 2019-12-12 03:11:58
问题 I am new to shell scripting and having a doubt regarding the usage of &- I have a shell script with a single line: echo Hello . The shell script is named demo.sh What does it do when it is executed as: ./demo.sh 0>&- Thanks. 回答1: It closes the file descriptor - standard input (0) in this case. See also: http://www.tldp.org/LDP/abs/html/io-redirection.html 来源: https://stackoverflow.com/questions/38782395/redirecting-the-output-of-shell-command-to-what-does-it-mean

Grep output of command and use it in “if” statement, bash

别说谁变了你拦得住时间么 提交于 2019-12-12 02:45:43
问题 Okay so here's another one about the StarMade server. Previously I had this script for detecting a crash, it would simply search through the logs: #!/bin/bash cd "$(dirname "$0")" if ( grep "[SERVER] SERVER SHUTDOWN" log.txt.0); then sleep 7; kill -9 $(ps -aef | grep -v grep | grep 'StarMade.jar' | awk '{print $2}') fi It would find "[SERVER] SERVER SHUTDOWN" and kill the process after that, however this is not a waterproof method, because with different errors it could be possible that the

Redirect print output to file in Python

谁都会走 提交于 2019-12-12 02:05:04
问题 I am trying to redirect print output to a file in Python 3.4 - right now as it stands my script prints to the shell. I don't really need it to do that. Here's my code: with open('Input.txt') as namelist: for line in namelist: line_lower = line.lower() a = namelist.readline() if fuzz.ratio(a, line) >= 95: print(fuzz.ratio(a, line)) print(a + ": " + line) I'd really like for what prints out as a result of this: print(fuzz.ratio(a, line)) print(a + ": " + line) To output to a text file. What I

Process class not printing echo output c#

孤者浪人 提交于 2019-12-12 01:57:15
问题 Due to the old question extended a lot, without working answers (but usefull), I would like to remodel it. The fact is in cmd all is working well, but not it c#. If the shared resource exist, the output of net use in c# is correct: 'Command completed' (in my case, in Spanish). But when the shared resource doesn't exist the echo 'false' works in cmd, but don't in c#, so I can't difference in the method what happened (user privilege or resource not found). In c# I tried: String cmd = "....else

matlab for loop function multiple output in matrix

China☆狼群 提交于 2019-12-12 01:43:05
问题 I am looking to create two separate matrices with a for loop over a function that creates two outputs. It looks somewhat like this: % prepare output matrixes output1=zeros(size(input2),1) % corresponds to a vector of length n of the nodes (bank capital levels in this case) output2=zeros(size(input2)) % corresponds to an adj matrix of size n input2=[100,200,300 ... ] % corresponds to a vector of length n with capital levels. input1=1:length(input2); % correspounds to vector of [1:n] of

Array returning memory allocation instead of value in Java [duplicate]

我的梦境 提交于 2019-12-12 01:09:43
问题 This question already has answers here : How do I print my Java object without getting “SomeType@2f92e0f4”? (10 answers) Closed 4 years ago . Consider a simple case like this one : public static void array() { String myString = "STACKOVERFLOW"; int [] checkVal = new int[myString.length()]; for(int i=0; i<myString.length();i++){ checkVal[i] = (int)myString.charAt(i); } System.out.println(checkVal[0]); System.out.println(checkVal[1]); System.out.println(checkVal[2]); System.out.println(checkVal

Output not displayed with usleep until a line break is given

耗尽温柔 提交于 2019-12-12 01:08:26
问题 I'm trying to program a simple "typewriter" effect in C, where text appears one letter at a time with a delay. Here's the function I have: #include <stdio.h> #include <unistd.h> void typestring(const char *str, useconds_t delay) { while (*str) { putchar(*(str++)); usleep(delay); } } The problem is the text doesn't actually appear until a \n is displayed. What am I doing wrong? 回答1: The output to stdout is buffered. Using \n you are forcing a flush. If you want to change this, you will need to