My exe does not pass anything to logfile (jampded.exe) [duplicate]

拜拜、爱过 提交于 2019-12-11 21:02:03

问题


I want to create a simple handler for my game server. It will read the console directly and take any action i want. BUT! I can't pass the output from the server to my exe or txt.

ping google.com > ping.log

It works fine, everything will be logged in my log file. Also I created an exe, that can read the output data this way:

ping google.com | my.exe

It also works fine, my exe's content is:

#include <iostream>
#include <windows.h>

using namespace std;

int main() {
    string input = "";
    while(cin) {
        getline(cin, input);
        cout << input << endl;
    };
    system("pause");
}

It shows everything line by line.

The problem is with the jampded.exe. If I start it with a batch file, it has output in the console window, but I can not pass this for my log file, or my.exe. I have no idea.

I put cout-s in my code, so it shows it is stucking in the while loop. getline waits for cin, but nothing passed.. But why?


回答1:


Your program may use stderr to output data.

Try to replace jampded.exe | yourprogram.exe by jampded.exe 2| yourprogram.exe




回答2:


I am unfamiliar with jampded, but normally, a server will output some start messages to the console, and then detach itself from the console input/output, so it can run in the background. Any further messages may be written to a log file.

It is possible that you can start jampded with command line or configuration file options to keep writing to the console. Or you could read the log file. (For which I normally use "tail.exe -f" from the gnuwin32 file utils.)

A quick search on google also shows that there is a non-dedicated server version called jamp.exe. For testing purposes it may offer more flexibility to capture the output.



来源:https://stackoverflow.com/questions/17064302/my-exe-does-not-pass-anything-to-logfile-jampded-exe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!