stdout

X86 read from stdin and write to stdout without referring the standard library

六月ゝ 毕业季﹏ 提交于 2020-12-30 03:56:06
问题 I'm a beginner in X86 assembly language. I know how to read from stdin and write to stdout using build-in functions, but I'm not sure how to do it with plain assembly code(i.e. manipulating registers and taking advantage of system calls). #include <stdio.h> #include <unistd.h> int main(){ /* copy input to output */ char buf[BUFSIZ]; int n; while ((n = read(0, buf, BUFSIZ)) > 0) write(1, buf, n); return 0; } This is the C code I wrote to first read from the standard input (represented by

X86 read from stdin and write to stdout without referring the standard library

做~自己de王妃 提交于 2020-12-30 03:55:50
问题 I'm a beginner in X86 assembly language. I know how to read from stdin and write to stdout using build-in functions, but I'm not sure how to do it with plain assembly code(i.e. manipulating registers and taking advantage of system calls). #include <stdio.h> #include <unistd.h> int main(){ /* copy input to output */ char buf[BUFSIZ]; int n; while ((n = read(0, buf, BUFSIZ)) > 0) write(1, buf, n); return 0; } This is the C code I wrote to first read from the standard input (represented by

X86 read from stdin and write to stdout without referring the standard library

廉价感情. 提交于 2020-12-30 03:55:33
问题 I'm a beginner in X86 assembly language. I know how to read from stdin and write to stdout using build-in functions, but I'm not sure how to do it with plain assembly code(i.e. manipulating registers and taking advantage of system calls). #include <stdio.h> #include <unistd.h> int main(){ /* copy input to output */ char buf[BUFSIZ]; int n; while ((n = read(0, buf, BUFSIZ)) > 0) write(1, buf, n); return 0; } This is the C code I wrote to first read from the standard input (represented by

Capture both stdout & stderr via pipe

可紊 提交于 2020-12-30 02:44:04
问题 I want to read both stderr and stdout from a child process, but it doesn't work. main.rs use std::process::{Command, Stdio}; use std::io::{BufRead, BufReader}; fn main() { let mut child = Command::new("./1.sh") .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn() .unwrap(); let out = BufReader::new(child.stdout.take().unwrap()); let err = BufReader::new(child.stderr.take().unwrap()); out.lines().for_each(|line| println!("out: {}", line.unwrap()) ); err.lines().for_each(|line| println!(

Capture both stdout & stderr via pipe

£可爱£侵袭症+ 提交于 2020-12-30 02:43:29
问题 I want to read both stderr and stdout from a child process, but it doesn't work. main.rs use std::process::{Command, Stdio}; use std::io::{BufRead, BufReader}; fn main() { let mut child = Command::new("./1.sh") .stdout(Stdio::piped()) .stderr(Stdio::piped()) .spawn() .unwrap(); let out = BufReader::new(child.stdout.take().unwrap()); let err = BufReader::new(child.stderr.take().unwrap()); out.lines().for_each(|line| println!("out: {}", line.unwrap()) ); err.lines().for_each(|line| println!(

PHP: How to use monolog to log to console (php://out)?

放肆的年华 提交于 2020-12-28 05:51:05
问题 I just switched to monolog and wanted to log my message to the PHP console instead of a file. This might seem obvious for some people, but it took me a little while to figure out how to do that and I couldn't find a similar question/answer on SO. The example on Monolog's Github readme only shows how to use a file: <?php use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger:

PHP: How to use monolog to log to console (php://out)?

时光总嘲笑我的痴心妄想 提交于 2020-12-28 05:47:08
问题 I just switched to monolog and wanted to log my message to the PHP console instead of a file. This might seem obvious for some people, but it took me a little while to figure out how to do that and I couldn't find a similar question/answer on SO. The example on Monolog's Github readme only shows how to use a file: <?php use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger:

PHP: How to use monolog to log to console (php://out)?

荒凉一梦 提交于 2020-12-28 05:43:04
问题 I just switched to monolog and wanted to log my message to the PHP console instead of a file. This might seem obvious for some people, but it took me a little while to figure out how to do that and I couldn't find a similar question/answer on SO. The example on Monolog's Github readme only shows how to use a file: <?php use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger:

PHP: How to use monolog to log to console (php://out)?

[亡魂溺海] 提交于 2020-12-28 05:42:38
问题 I just switched to monolog and wanted to log my message to the PHP console instead of a file. This might seem obvious for some people, but it took me a little while to figure out how to do that and I couldn't find a similar question/answer on SO. The example on Monolog's Github readme only shows how to use a file: <?php use Monolog\Logger; use Monolog\Handler\StreamHandler; // create a log channel $log = new Logger('name'); $log->pushHandler(new StreamHandler('path/to/your.log', Logger:

python - logging stdout, but getting second blank line on each entry

对着背影说爱祢 提交于 2020-12-26 06:58:55
问题 I'm on a Linux Ubuntu 12.04 system. I have been using this code to log all stdout and stderr + additional logging on INFO level to a file.. class LogFile(object): def __init__(self, name=None): self.logger = logging.getLogger(name) def write(self, msg, level=logging.INFO): self.logger.log(level, msg) def flush(self): for handler in self.logger.handlers: handler.flush() logging.basicConfig(level=logging.INFO, format='%(asctime)s %(name)-12s %(levelname)-8s %(message)s', datefmt='%m-%d-%y %H:%M