output

Save cURL Display Output String in Variable PHP

五迷三道 提交于 2019-11-28 10:50:25
is their an option to save the outpout of a curl request in a php variable? Because if i only save the $result i get a 1 or nothing <?php $url='http://icanhazip.com'; $proxy=file ('proxy.txt'); $useragent='Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)'; for($x=0;$x<count($proxy);$x++) { $ch = curl_init(); //you might need to set some cookie details up (depending on the site) curl_setopt($ch, CURLOPT_TIMEOUT, 1); curl_setopt($ch, CURLOPT_URL,$url); //set the url we want to use curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0); curl_setopt($ch, CURLOPT_PROXY, $proxy[$x]); curl_setopt($ch,

Implementing input/output redirection in a Linux shell using C

↘锁芯ラ 提交于 2019-11-28 10:41:09
问题 I am trying to create a basic shell for Linux using C. I have gotten it to work until I try to do output redirection and it just destroys everything. When I run this code, it goes straight to the default case of the fork(). I have no idea why. If I get rid of the for loop in the child process it works, but even with the for loop I don't understand why the child process is never even entered. If I put a print statement at the top of the child process it doesn't get printed. When I run this in

redirecting cout into file c++

别等时光非礼了梦想. 提交于 2019-11-28 10:17:16
问题 my problem is I have a couple of cout's in various files in the project. I would like all of them to be redirected and saved in .txt file, and what I achieved by now is that only one cout is saved in the file. I don't want to create separate .txt for each cout , for the sake of reading them at once. My code looks now like this: #include <fstream> #include <string> #include <iostream> int main() { std::ofstream out("out.txt"); std::cout.rdbuf(out.rdbuf()); std::cout << "get it3"; std::cout <<

How to determine if an output of a function-call is unused?

人走茶凉 提交于 2019-11-28 09:43:44
Say I have a function foo that can return three values given an input: function [a,b,c] = foo(input) The calculations of variables b and c take a long time, so sometimes I may wish to ignore their calculation within foo . If I want to ignore both calculations, I simply call the function like this: output1 = foo(input); and then include nargout within foo : if nargout == 1 % Code to calculate "a" only else % Code to calculate other variables The problem occurs if I want to calculate the last output, but not the second. In that case my function call would be: [output1,~,output3] = foo(input);

What is the fastest way to output large DataFrame into a CSV file?

限于喜欢 提交于 2019-11-28 09:42:59
For python / pandas I find that df.to_csv(fname) works at a speed of ~1 mln rows per min. I can sometimes improve performance by a factor of 7 like this: def df2csv(df,fname,myformats=[],sep=','): """ # function is faster than to_csv # 7 times faster for numbers if formats are specified, # 2 times faster for strings. # Note - be careful. It doesn't add quotes and doesn't check # for quotes or separators inside elements # We've seen output time going down from 45 min to 6 min # on a simple numeric 4-col dataframe with 45 million rows. """ if len(df.columns) <= 0: return Nd = len(df.columns) Nd

Outputting variable values in x86 asm

…衆ロ難τιáo~ 提交于 2019-11-28 09:40:40
问题 I am writing a program in assembly and it isn't working, so I'd like to output variables in x86 functions to ensure that the values are what I expect them to be. Is there a simple way to do this, or is it very complex? If it makes it simpler, the assembly functions are being used from C functions and are being compiled with gcc. 回答1: It appears that your question is along the lines of "How can I print out variable values in x86 assembler". The x86 itself doesn't know how to do that, because

Java: println with char array gives gibberish

时光总嘲笑我的痴心妄想 提交于 2019-11-28 09:39:36
Here's the problem. This code: String a = "0000"; System.out.println(a); char[] b = a.toCharArray(); System.out.println(b); returns 0000 0000 But this code: String a = "0000"; System.out.println("String a: " + a); char[] b = a.toCharArray(); System.out.println("char[] b: " + b); returns String a: 0000 char[] b: [C@56e5b723 What in the world is going on? Seems there should be a simple enough solution, but I can't seem to figure it out. When you say System.out.println(b); It results in a call to print(char[] s) then println() The JavaDoc for print(char[] s) says: Print an array of characters.

Freeze when programmatically launching a batch file (with output redirection), when the batch file simply calls “start some.exe”

廉价感情. 提交于 2019-11-28 09:33:15
问题 EDIT: Found some duplicates with no answers: Issue with output redirection in batch How do I use the "start" command without inheriting handles in the child process? I have some C# code that tries to be a generic process launcher, within a larger long-running program. This code needs to capture the output from the processes it launches, and also wait for them to finish. We typically launch batch files with this code, and everything works fine, except when we want to start another child

How to position the input text cursor in C?

主宰稳场 提交于 2019-11-28 07:45:16
Here I have a very simple program: printf("Enter your number in the box below\n"); scanf("%d",&number); Now, I would like the output to look like this: Enter your number in the box below +-----------------+ | |*| | +-----------------+ Where, |*| is the blinking cursor where the user types their value. Since C is a linear code, it won't print the box art, then ask for the output, it will print the top row and the left column, then after the input print the bottom row and right column. So, my question is, could I possibly print the box first, then have a function take the cursor back into the

CMake: setting an environmental variable for ctest (or otherwise getting failed test output from ctest/make test automatically)

江枫思渺然 提交于 2019-11-28 07:11:31
I want ctest to show me the failed tests output by default. That is, I want to run: $ make all test and see any output of failed tests without having to cat Testing/Temporary/LastTest.log . It appears that there are two ways of doing this: (1) Setting the CTEST_OUTPUT_ON_FAILURE environmental variable: $ CTEST_OUTPUT_ON_FAILURE=1 make all test $ # or CTEST_OUTPUT_ON_FAILURE=1 ctest (2) Specifying the --output-on-failure flag to the ctest invocation: $ ctest --output-on-failure Is there a way to write a CMakeLists.txt file such that ctests dumps failed tests output by default on a normal "make