FAQ Database Discussion Community


How can I get unicode characters from robocopy process standard ouput in c#

c#,unicode,process,stdout,robocopy
Our application runs various actions and displays the output in a log window. One action uses robocopy to copy files between folders. This works ok until the robocopy output contains unicode characters. I understand that I need to use the /unicode option but all I seem to get back is...

one stdout to one stdin from java to python

java,python,stdout,stdin
I am having this java code public static main void (String[] args) { System.out.println("this is iteration 1"); System.out.println("this is iteration 2"); System.out.println("this is iteration 3"); System.out.println("this is iteration 4"); } Python import sys try: while True: data = raw_input() print "in python " + data except: print error Desired output...

Garbage char returned by Shell.StdOut.ReadAll

batch-file,vbscript,stdout
Here is my code Set objFSO = CreateObject("Scripting.FileSystemObject") a = "@echo off && " & _ "pushd ""\\xxxxx.local\cfs\Development\Docs\Baseline"" &&" & _ "cls &&" & _ "dir /b /a-d &&" & _ "popd" Set objShell = CreateObject("WScript.Shell").Exec("%comspec% /c " & a) execStdOut = objShell.StdOut.ReadAll() msgbox execStdOut Basically I am trying to...

On a Linux system, how would I redirect stdout to stderr?

linux,stdout,stderr
I think its the case that you can't just assign the stdout to stderr because other things might have already cached (?) stdout by the time the reassignment takes place. So how do I do this (using Linux)? ...

What is the proper way to remove a stream from stdout so that another stream may be added?

asynchronous,stream,dart,stdout
I am starting a process in Dart that attaches its stdout stream to stdout so that the results can be printed to the terminal like so: Process.start(executable, ['list','of','args']).then((proc) { stdout.addStream(proc.stdout); stderr.addStream(proc.stderr); return proc.exitCode; }); However, once this completes I would like to start a new process and begin this again...

No colour output if program run with exec

c,linux,stdout
I have a C program that runs execvp("grep", args); Where args is an array {"grep", "test"} (test being the word I want grep to find). The issue is that grep's output is not coloured. In a normal bash shell, grep highlights test in red, but in my program's output it...

Paging output from Go

go,stdout,pager
I'm trying print to stdout from golang using $PAGER or manually invoking more or less to allow the user to easily scroll through a lot of options. How can I achieve this?

node.js: Cannot read property 'defaultEncoding' of undefined

node.js,process,stdout
I wanted to write a changeable write() function. var write = function(s) { process.stdout.write(s); } write("Hello world!"); I thought you could just write it shorter: var write = process.stdout.write; write("Hello world!"); But here I will receive this error: TypeError: Cannot read property 'defaultEncoding' of undefined at Writable.write (_stream_writable.js:172:21) at Socket.write...

How to pipe tar.extractall from python

python,stdout,tar
I'm extracting a tarball using the tarfile module of python. I don't want the extracted files to be written on the disk, but rather get piped directly to another program, specifically bgzip. I'm also trying to use StringIO for that matter, but I get stuck even on that stage -...

See stdout when running bash script in PyCharm

python,bash,stdout,pycharm
I use a bash script to call several python scripts. I installed the bash plugin for PyCharm. I can run the script, but I don't see stdout during runtime, even though I see it after everything finished. How can I make that visible during runtime?

BASH: Run script.sh in background and output that instance's pid to file?

linux,bash,shell,stdout,pid
I'm sure this is probably a shamefully daft question, but it feels like I've done two laps of the web reading things about process management, output redirection etc. but I'm struggling to make sense of it all enough to achieve what I'd like. In essence: I want to run a...

STDOUT does not work programmatically via Groovy API

linux,grails,cmd,stdout
Using espeak command to generate an audio espeak "Hello Mr. Toumi" --stdout > /tmp/audio123.wav When i run this command using terminal , it works fine . Prepare now in API for this command in Grails Service #EspeakService.groovy File speak(String message){ Process pr='espeak "'+message+'" --stdout > '+filePath(message); pr.waitFor() return new File(filePath(message));...

Python subprocess with /usr/bin/time: how to capture timing info but ignore all other output?

python,python-2.7,time,stdout,stderr
I am trying to measure the execution time in seconds of a executable program invoked via subprocess. I do not want the output of the executable (either stderr or stdout) to be emitted. I have tried the timeit and resource libraries, but neither accurately captures the time of the process,...

Can multiple programs write to STDOUT at the same time?

python,multithreading,parallel-processing,multiprocessing,stdout
I'm currently using GNU Parallel to run a Python script on multiple large files simultaneously. I have a master Python script that sets up the files I need to process, and then dispatches Parallel to run the same worker script on these files. I need to get the data back...

Catch stdout using java

java,stdout,execute
What is the best way, how to catch stdout using java? Demonstration: PROGRAM A start PROGRAM B, PROGRAM B print some output to console (using System.println("...")), how can i catch from PROGRAM A output in console from PROGRAM B? My way is: start Program B and redirect the output to...

Redirect files from Popen to subdirecotry

python,redirect,subprocess,stdout,popen
I have a pipeline composed of a number of scripts. Almost all of the scripts read and write to files, and some of the scripts in the pipeline have conflicting file formats (they will read and attempt to perform actions on files that they should not due to the files...

linux stdin, stdout pipe

linux,pipe,stdout,stdin
I have a brick.sprite. I have a executable in Debain 8 "Kali Linux" with this code: #include <stdio.h> #include <stdint.h> #include <iostream> /** * To use this file, pipe a sprite of the old format into stdin, and * redirect stdout to a second file of your chosing. The sprite...

NodeJS child process stdout are all numbers

node.js,stdout,child-process
I'm writing some node.js scripts to kick off a child process. Code snippet is as below. var spawn = require('child_process').spawn; var child = spawn ('node', ['script.js']) child.stdout.on('data', function (data) { logger.verbose('tail output: ' + JSON.stringify(data)); } ); child.stderr.on('data', function (data) { logger.error('err data: ' + data); } ); Script runs...

How to block writes to standard output in java (System.out.println())

java,logging,stdout
In Java, how to block code from writing to system out? My app calls a 3rd party library that spams logs by issuing numerous System.out.println() calls. I don't have legal rights to decompile and patch the library. I'm running Websphere 8.5.x Considered using System.setOut(PrintStream out), but that will effect the...

Getting process STDOUT - Mac OS X

java,osx,stdout
I made a Mac OS X (native) application that writes one line on STDOUT. In a Java program, I need to launch that application and get what it writes on the standard output. The following code works for Windows applications but not for Mac OS X apps. ProcessBuilder pb =...

How do I Print a Hash Table in C?

c,hashtable,stdout
I have a program in C that creates a hash table. I want to know what it is, but I am unsure how to print it out or display it. I have pasted the program below. I am rather new to hash tables so any help would be greatly appreciated!...

How to redirect STDOUT of subscript into variable in ruby 2.1.6

ruby,stdout
Here is my full code so far: if ARGV.size == 0 print "Set a library name as parameter" else dir = ARGV[0] begin Dir.chdir "#{dir}" rescue print "No such library" else filelist = Dir.glob "*.rb" outfile = "result" i = 0 while i < filelist.size do filename = filelist[i] output...

redirect stderr stdout both on console and log file

linux,bash,stdout,stderr
I am using a C API in order to manage my bluetooth thru bluetoothctl. It works by using command like : ./BT_API connect $2 | bluetoothctl > /tmp/BT_TMP All is stored within /tmp/BT_TMP but noting on screen. I tried by using the following command ./BT_API connect $2 | bluetoothctl 2>&1...

Send stderr/stdout messages to function and trap exit signal

bash,shell,unix,stdout,stderr
Im working on error handling and logging in my bash script. Below I have included a simplified code snippet that exemplify the use case. I want to achieve following in my script: trap exit signals which should trigger onexit() function in the code below stderr and stdout should be sent...

PYTHON subprocess cmd.exe closes after first command

python,cmd,subprocess,stdout,stdin
I am working on a python program which implements the cmd window. I am using subproccess with PIPE. If for example i write "dir" (by stdout), I use communicate() in order to get the response from the cmd and it does work. The problem is that in a while True...

modifying shell stdout in real time

bash,shell,text,scripting,stdout
Ok so bear with me as I am not a professional, this is a proof of concept project to learn more about my shell, programming and just basic bash scripting. So WHAT I WANT TO DO is: whenever anything is printed out in my terminal, be it the result of...

Piping stdout of Process to another stdout

process,stdout,rust
I'm trying to start a curl download and then pipe it's stdout to the stdout of my program. Here's what I got (still using old_io): let process = Command::new("curl") .arg("-o ").arg(&self.filename).arg(&self.url) .spawn().ok().expect("Download failed."); let output = process.wait_with_output().ok().expect("Download failed."); That works perfectly fine, but the curl download takes quite a long...

What does >>& mean in a tcsh script and how does it translate to bash?

bash,stdout,stderr,tcsh
I'm converting a tcsh script to bash, hit a snag because I'm not entirely sure what >>& does wget --output-document=/dev/null "http://somewebsite.org" >>& /root/wget.log I did read the man-page http://linux.die.net/man/1/tcsh but not sure what "route the diagnostic" means, probably stderr... so, just to be absolutely sure, is it the same as...

Threading script not printing to console

python,stdout,python-multithreading
this is really baffling me, and I cannot find the answer. import thread import time import random import sys sys.stdout.flush() def run_often(thread_name, sleep_time): while True: time.sleep(sleep_time) print "%s" % (thread_name) def run_randomly(thread_name, sleep_time): while True: time.sleep(sleep_time) print "%s" % (thread_name) thread.start_new_thread(run_often,("Often runs", 2)) thread.start_new_thread(run_randomly, ("Fast and random", random.random())) the problem...

Python get script output with now only the pid of file

python,stdout,pid
for example I run a script os.execv('script.py',('',)) As I read in docs this command starts a script from your current script by taking it's pid and reasigning it to run script.py. So I can get the pid of process. The question is following: After running execv I need to get...

Grunt not outputting, returning error

node.js,maven,gruntjs,output,stdout
I run a website which uses Grunt to collect all of my assets into a compiled bundle (translating Less into CSS, translating TS into JS, running tests, etc.). I recently moved to a new computer. Although my source files (including package.json, Gruntfile, pom.xml, etc.) are store in the project's Git...

Redirect c library stdout messages in Python

python-2.7,stdout,gtk3,libvlc,libav
I have a GUI application in Python 2.7 using Gtk+ 3.10.8 running on Linux Mint 17.1. The application uses the python bindings for the libvlc library to embed a video player. The libvlc library uses libav for its video handling. My problem is that libav is extremely verbose and generates...

PHP exec() nohup with redirect

php,exec,stdout,stderr,nohup
I am trying to execute a command with exec() and redirecting stdout and stderr to a file. exec("nohup python main.py -i 1 > /var/scripts/logs/1_out.log 2>&1 &"); It will create the file but it wont print anything to it. If I run the command in a terminal everything write without a...

Can I use a StreamHandler for Logging in a Multiprocessing Environment in Python?

python,logging,multiprocessing,stdout
Is it safe to use a single StreamHandler in a multiprocessing environment? More precisely, can it be problematic to have a just one StreamHandler that simply prints the logging statements of all processes to stdout? Like this, for example: import multiprocessing as mp import logging def do_log(no): # 2nd EDIT,...

how to reattach sys.stdout to console window in python?

python,io,stdout,stringio,redirectstandardoutput
My python 3 doodling went like this: import io, sys sys.stdout = io.StringIO() # no more responses to python terminal funnily enough My question is how to reattach so when I pass in 1+1 for example it'll return with 2 to the console? This is in the python interpreter on...

IO Redirection in Linux Bash shell scripts not recreating moved/deleted file?

linux,bash,stdout,stderr,io-redirection
I am quite new to shell programming on Linux and in my Linux instance, I am redirecting the stdout and stderr of a program to two files in following manner and run it in background myprog > run.log 2>> err.log & This works fine, and I get my desired behavior...

maya python subprocess error

python-2.7,subprocess,stdout,maya
in python 2.7 i try this code to get data from Deadline software. Its return some data from server... import subprocess path = 'C:/Program Files/Thinkbox/Deadline7/bin/' p1 = subprocess.Popen([path + 'deadlinecommand.exe', 'pools'], stdout=subprocess.PIPE) p1.communicate() and see result: ('none\r\npool_01\r\npool_02\r\npool_03\r\npool_04\r\npool_05\r\npoolhalf\r\n', None) but when i copy that code to python in maya 2014 i...

stdout and stderr redirection in child process

bash,unix,process,stdout,stderr
If I run a Bash script like this: ./script.sh 2>&1 stderr will be redirected to stdout. If the script calls some tool inside (e.g. ls) or spawns a new process, will these child processes have their stderr also redirected to stdout?...

Redirect output from file to stdout

bash,shell,unix,stdout
I have a program that can output its results only to files, with -o option. This time I need to output it to console, i.e. stdout. Here is my first try: myprog -o /dev/stdout input_file But it says: /dev/ not writable I've found this question that's similar to mine, but...

Can oddly not print to stdout after a certain print line? [duplicate]

c,unix,stdout
This question already has an answer here: Why does printf not flush after the call unless a newline is in the format string? 9 answers Ok, so I was putting in prints to investigate where my program stopped executing, it seems I simply cannot print to stdout after a...

“print” not working when redirecting to another application

python,windows,redirect,printing,stdout
I ran across this strange problem when redirecting the output of a python application. I was running bitmessage from source which prints quite a big amount of stuff to the console. I tried filtering out some of the lines with an application I have written. When I redirect the output...

Combine Grep and Regex?

ruby,regex,input,while-loop,stdout
Have a list of smaller network elements that i am trying to list in the stdout. My small little script works up until the regex, after i get prompted what i want to search for it lists the whole line. Example: Please Enter a Region Input: Bei Output: ipc-bei640-r-br-01 ipc-bei640-r-br-02...

Process in python - fetch stdout of non-terminating process

python,subprocess,stdout
Suppose there is a program that produces different outputs with different inputs, and terminates if the input is a specific value. For example, it can be written in C++: int main() { int i; while(true) { cin >> i; if (i) cout << i << endl; else break; } return...

Perl: comparing words in two files

perl,file-io,stdout
This is my current script to try and compare the words in file_all.txt to the ones in file2.txt. It should print out any of the words in file_all that are not in file2. I need to format these as one word per line, but that's not the more pressing issue....

Writing regex result into a new file

ruby,regex,stdout
I've got a list of devices: ipc-bei640-r-br-01 ipc-bei640-r-br-02 ipc-bei640-r-br-03 ipc-bei640-r-br-04 ipc-bei640-r-br-05 ipc-bem640-r-br-01 ipc-bem640-r-br-02 ipc-bem640-r-br-03 ipc-crg660-r-br-02 ipc-geb680-r-br-04 ipc-lgv630-r-br-01 This small little ruby script counts the lines of the file braslist.txt scans it with a regex and writes the results to a newfile called "strippedfile.txt" lines = IO.readlines("/usr/local/bin/braslist.txt") # Linecount is forwarded...

Why does returning in Interactive Python print to sys.stdout?

python,return,stdout,python-idle
I ran into something different today. Consider this simple function: def hi(): return 'hi' If I call it in a Python shell, >>> hi() 'hi' >>> print hi() hi It prints out the 'returned' value, even if it's just the repr. This felt odd to me, how could returning be...