output-redirect

Execution output to text file

﹥>﹥吖頭↗ 提交于 2020-01-05 09:34:20
问题 I am writing a C program using Visual Studio 2008. I use F7 to compile and F5 to execute the program.When I press F5 an execution window contains the output. But I want the output to get saved to a text file. How to do this in visual studio. Please help me someone. 回答1: I think using the command line parameter > output path will do the trick. for example: myapp.exe >D:\result.txt will direct the app output to result.txt file. If you running the application from within Visual Studio, you can

Difference between $stdout and STDOUT in Ruby

不问归期 提交于 2019-12-17 15:24:22
问题 In Ruby, what is the difference between $stdout (preceded by a dollar sign) and STDOUT (in all caps)? When doing output redirection, which should be used and why? The same goes for $stderr and STDERR . Edit: Just found a related question. 回答1: $stdout is a global variable that represents the current standard output. STDOUT is a constant representing standard output and is typically the default value of $stdout . With STDOUT being a constant, you shouldn't re-define it, however, you can re

Redirect process output C#

↘锁芯ラ 提交于 2019-12-17 09:58:49
问题 I would like to redirect the Process's standard output to a string for later parsing. I would also like to see the output on the screen, while the process is running, and not only when it finishes it's run. Is that even possible? 回答1: Use RedirectStandardOutput. Sample from MSDN: // Start the child process. Process p = new Process(); // Redirect the output stream of the child process. p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.FileName =

How to execute system commands (linux/bsd) using Java

蓝咒 提交于 2019-12-16 21:08:53
问题 I am attempting to be cheap and execute a local system command ( uname -a ) in Java. I am looking to grab the output from uname and store it in a String. What is the best way of doing this? Current code: public class lame { public static void main(String args[]) { try { Process p = Runtime.getRuntime().exec("uname -a"); p.waitFor(); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); String line=reader.readLine(); while (line != null) { System.out.println

How to discard the output from a system command?

五迷三道 提交于 2019-12-14 03:28:13
问题 I recently wrote this code to execute system command in C. I just want to measure time performed by this system command. However, I don't want the output results to be displayed upon executing this program. #include <stdio.h> int main(int argc, char* argv[]) { system("ls"); return 0; } How do I discard the output from the system command? 回答1: When you call system() from C, a shell is invoked to interpret your command. This means you can use shell redirects: system("ls > /dev/null"); and if

Linux cron job to email output from a command

南楼画角 提交于 2019-12-12 02:10:17
问题 I would like to run a cron job to backup some mysql databases by piping the output to a file and then emailing it. Will the following work? 15 2 * * * root mysqldump -u root -pPASSWORD --all-databases | \ gzip > /database_`data'+%m-%d-%Y'`.sql.gz | \ mail -s "Report 05/06/07" user@example.com < /database_`data'+%m-%d-%Y'`.sql.gz 回答1: There are a couple of problems with your script, I have altered it below, note carefully the change of spaces, spelling of date and replacement of | for ; . The

Problem redirecting stdout in Ruby script

感情迁移 提交于 2019-12-07 18:32:32
问题 I have the following test Ruby script: require 'tempfile' tempfile = Tempfile.new 'test' $stderr.reopen tempfile $stdout.reopen tempfile puts 'test stdout' warn 'test stderr' `mail -s 'test' my@email.com < #{tempfile.path}` tempfile.close tempfile.unlink $stderr.reopen STDERR $stdout.reopen STDOUT The email that I get has the contents: test stderr Why is stderr redirecting properly but not stdout? Edit: In response to a comment I added a $stdout.flush after the puts line and it printed

How can I output Handbrake output to both the screen and to a file?

随声附和 提交于 2019-12-02 05:48:35
问题 So I've been using Handbrake command line to encode my video collection to store on my NAS so I can use it on my HTPC. I was looking for a way to output both to the screen so I can watch it's output as it's encoding, but also to a file so I can go back and look at a particular encoding session. My solution for this was to use one Powershell window to run the encoding and output to a file, then another Powershell window to read the log file and display it on screen. This works, but I want to