stdout

Linux - Send STDOUT of command to an RSS Feed

被刻印的时光 ゝ 提交于 2019-12-01 14:53:19
I'm looking to use a personal RSS Feed for system reporting, so I'm wondering if it's possible to create a script that sends its $1 to an RSS feed, ala self_test_command > rss_report.sh . I don't currently have an RSS feed set up, either, so what would be the easiest way to set up an RSS feed running from a Linux box? I have a proper solution for you, in command line . That use Perl Template::Toolkit module in background (no need to learn Perl just now) : first install the package perl-template-toolkit , then create the template file rss.tpl : <?xml version="1.0" encoding="utf-8"?> <rss

How to capture the output of system()

浪尽此生 提交于 2019-12-01 13:54:06
问题 This question was motivated by Rmarkdown not outputting results of system command to html file. For some reason, the output of system() in R (or system2() ) cannot be captured by sink() or capture.output() , so currently there is no way for knitr to record the output. For example, in the R console: > system('ls') DESCRIPTION NAMESPACE R README.md inst man but in a knitr document, you won't see the output, because capture.output(system('ls')) is character(0) , i.e. the output cannot be

how to give subprocess a password and get stdout at the same time

南楼画角 提交于 2019-12-01 13:16:58
I'm trying to check for the existence of an executable on a remote machine, then run said executable. To do so I'm using subprocess to run ssh <host> ls <file> , and if that's successful, run ssh <host> <file> . ssh asks for a password, of course, and I'd like to provide that automatically. Also, I'd like to get the returncode from ls, and stdout and stderr from running the command. So I know the communicate() method is needed, to avoid deadlocks, but I can't get the password to be recognized by Popen(stdin) . Also I'm using Python 2.4.3, and stuck on that version. Here's the code I've got so

calling bash from python

懵懂的女人 提交于 2019-12-01 12:59:32
I have a python script which calles a bash script. The bash script compiles several modules and I would like to seethe result of the compilation printed on screen while running. Most important, anyway, is that the bash script requires a run time quite some few input from the user. How can I make my python script give stdin/stdout to the bash script? For the moment I am using (_stat, _resl) = commands.getstatusoutput("./myBashScript") but in this way the user is not promped of anything while the bash is running... Cheers If you use subprocess (as you should!) and don't specify stdin/stdout

how to give subprocess a password and get stdout at the same time

旧时模样 提交于 2019-12-01 12:29:58
问题 I'm trying to check for the existence of an executable on a remote machine, then run said executable. To do so I'm using subprocess to run ssh <host> ls <file> , and if that's successful, run ssh <host> <file> . ssh asks for a password, of course, and I'd like to provide that automatically. Also, I'd like to get the returncode from ls, and stdout and stderr from running the command. So I know the communicate() method is needed, to avoid deadlocks, but I can't get the password to be recognized

putting CURL result in a string and not STDOUT?

南楼画角 提交于 2019-12-01 12:23:10
问题 I have the following curl code, which make a request to website and retrieve data from it, it works well, but I want to store my data in a string and not in the output window. Any idea? #include <stdio.h> #include <curl/curl.h> int main(void) { CURL *curl; CURLcode res; curl = curl_easy_init(); if(curl) { curl_easy_setopt(curl, CURLOPT_URL, "http://api.hostip.info/get_html.php?ip=xxx.xxx.xx.xxx"); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); res = curl_easy_perform(curl); if(res !=

Mongoose debug writes to STDERR?

我们两清 提交于 2019-12-01 11:21:23
First question, ahhhh! Does anyone know / have info about why mongoose writes its debug log to stderr? Is there anyway to write it to stdout? The debug option accepts a function instead of a boolean: mongoose.set("debug", function (collection, method, paramA, paramB, paramC) { console.log(collection) console.log(method) console.log(paramA) console.log(paramB) console.log(paramC) }) The reason I put paramA, paramB, paramC is because the arguments are dependent upon the method and options being used: Person.create({firstName: "john"}, callback) // people // insert // {firstName: "john"} //

fflush(stdout) in c

纵然是瞬间 提交于 2019-12-01 11:05:15
Right when I am at fflush(stdout) and I break there in GDB, can I know what is there in stdout before I actually print it? How can I know what is there in stdout at any point in time? You almost certainly can, but you probably shouldn't. The standard requires only that FILE be a type that is useful to the implementation to identify an open file and whatever state is required to implement the semantics of the various functions that operate on streams. I'd generally agree with other posters that fflush() is a reliable way to know what you actually wrote to the file. However, if you have lost

Show command line results in Tkinter text widget

孤人 提交于 2019-12-01 10:55:51
I want the output of a Python script in a Tkinter text widget instead of in the command line. I have this script from https://stackoverflow.com/a/665598/3524043 : from Tkinter import * import subprocess as sub p = sub.Popen('./Scripts/Speedtest.py',stdout=sub.PIPE,stderr=sub.PIPE, shell=True) output, errors = p.communicate() root = Tk() text = Text(root) text.pack() text.insert(END, output) root.mainloop() I've added shell=true at the subprocess, cause I had a OSError: [Errno 13] Permission denied . When I run the program there's only an empty text widget. Edited with a better solution: Import

Ncurses and Linux pipeline

爷,独闯天下 提交于 2019-12-01 10:40:38
I'd like to write a simple program using ncurses for displaying some data. I would then like for the program to write to stdout in such a way that I can then use a pipe (|) on the command line to pipe some data out. My current attempt doesn't work. I can see the "GOT HERE"'s in a file using '>', but there's a whole bunch of other stuff. The program also exits immediately. #include <stdio.h> #include <ncurses.h> int main(int _argc, char ** _argv) { initscr(); /* Start curses mode */ printw("Hello World !!!"); /* Print Hello World */ refresh(); /* Print it on to the real screen */ getch(); /*