RE: [hlcoders] Redirect server command output
Ya, it does. I'm thinking that somehow Msg() is bypassing write() or the stdout file descriptor or something. Is there a different trick that rcon uses to redirect output? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg Scott Sent: Friday, June 29, 2007 8:23 AM To: hlcoders@list.valvesoftware.com Subject: Re: [hlcoders] Redirect server command output -- [ Picked text/plain from multipart/alternative ] Did you try stepping through it in debug mode to make sure it's passing all the checks correctly? On 6/29/07, Tony Paloma [EMAIL PROTECTED] wrote: This is a multipart message in MIME format. -- [ Picked text/plain from multipart/alternative ] I'm trying to redirect the output of a server command to a file, but I'm having problems. I've come up with the following code (this code is within a ConCommand that I have written): char cmd[2048]; // clear out any pending commands first engine-ServerExecute(); // save the old stdout int oldstdout = dup(1); // redirect stdout to rcon.txt if writable FILE *fp = fopen(rcon.txt, w); if(fp) { dup2(fileno(fp), 1); } // prepare the command Q_snprintf(cmd, sizeof(cmd), %s\n, engine-Cmd_Args()); // just some tests puts(Test:); Msg(Cooltest\n); // queue the command engine-ServerCommand(msg); // actually execute the command engine-ServerExecute(); // more tests puts(posttest); Msg(coolposttest\n); // restore everything if we messed with anything if(fp) { // flush to make sure text gets written to file, not console fflush(stdout); fclose(fp); // put stdout back dup2(oldstdout, 1); // and close the duplicate close(oldstdout); flushall(); } When this code executes a command on the server (cvarlist for example), no output is written to the console but there is no relevant output in the rcon.txt file either. The contents of the rcon.txt file are: Test: posttest The tests using Msg() don't write to the file nor does the server command. Nothing is written to the console either, so it looks like the output gets lost somewhere. Why doesn't this work to redirect output of Msg()? I'm testing this in Windows. I'd be surprised if it didn't work in Linux as well since Linux seems to be more compliant with these sorts of things. Does anybody have any ideas or recommendations? -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
Re: [hlcoders] Redirect server command output
-- [ Picked text/plain from multipart/alternative ] did you try turning logging on? log on in the console? it redirects all text to a log file. On 6/30/07, Tony Paloma [EMAIL PROTECTED] wrote: Ya, it does. I'm thinking that somehow Msg() is bypassing write() or the stdout file descriptor or something. Is there a different trick that rcon uses to redirect output? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg Scott Sent: Friday, June 29, 2007 8:23 AM To: hlcoders@list.valvesoftware.com Subject: Re: [hlcoders] Redirect server command output -- [ Picked text/plain from multipart/alternative ] Did you try stepping through it in debug mode to make sure it's passing all the checks correctly? On 6/29/07, Tony Paloma [EMAIL PROTECTED] wrote: This is a multipart message in MIME format. -- [ Picked text/plain from multipart/alternative ] I'm trying to redirect the output of a server command to a file, but I'm having problems. I've come up with the following code (this code is within a ConCommand that I have written): char cmd[2048]; // clear out any pending commands first engine-ServerExecute(); // save the old stdout int oldstdout = dup(1); // redirect stdout to rcon.txt if writable FILE *fp = fopen(rcon.txt, w); if(fp) { dup2(fileno(fp), 1); } // prepare the command Q_snprintf(cmd, sizeof(cmd), %s\n, engine-Cmd_Args()); // just some tests puts(Test:); Msg(Cooltest\n); // queue the command engine-ServerCommand(msg); // actually execute the command engine-ServerExecute(); // more tests puts(posttest); Msg(coolposttest\n); // restore everything if we messed with anything if(fp) { // flush to make sure text gets written to file, not console fflush(stdout); fclose(fp); // put stdout back dup2(oldstdout, 1); // and close the duplicate close(oldstdout); flushall(); } When this code executes a command on the server (cvarlist for example), no output is written to the console but there is no relevant output in the rcon.txt file either. The contents of the rcon.txt file are: Test: posttest The tests using Msg() don't write to the file nor does the server command. Nothing is written to the console either, so it looks like the output gets lost somewhere. Why doesn't this work to redirect output of Msg()? I'm testing this in Windows. I'd be surprised if it didn't work in Linux as well since Linux seems to be more compliant with these sorts of things. Does anybody have any ideas or recommendations? -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders -- -omega -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
RE: [hlcoders] Redirect server command output
Yes, I understand that, but it's also buffered and therefore not written right away so I wouldn't be able to use the log file to see what the output was. Not to mention some output isn't written to the log. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tony omega Sergi Sent: Saturday, June 30, 2007 6:42 AM To: hlcoders@list.valvesoftware.com Subject: Re: [hlcoders] Redirect server command output -- [ Picked text/plain from multipart/alternative ] did you try turning logging on? log on in the console? it redirects all text to a log file. On 6/30/07, Tony Paloma [EMAIL PROTECTED] wrote: Ya, it does. I'm thinking that somehow Msg() is bypassing write() or the stdout file descriptor or something. Is there a different trick that rcon uses to redirect output? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg Scott Sent: Friday, June 29, 2007 8:23 AM To: hlcoders@list.valvesoftware.com Subject: Re: [hlcoders] Redirect server command output -- [ Picked text/plain from multipart/alternative ] Did you try stepping through it in debug mode to make sure it's passing all the checks correctly? On 6/29/07, Tony Paloma [EMAIL PROTECTED] wrote: This is a multipart message in MIME format. -- [ Picked text/plain from multipart/alternative ] I'm trying to redirect the output of a server command to a file, but I'm having problems. I've come up with the following code (this code is within a ConCommand that I have written): char cmd[2048]; // clear out any pending commands first engine-ServerExecute(); // save the old stdout int oldstdout = dup(1); // redirect stdout to rcon.txt if writable FILE *fp = fopen(rcon.txt, w); if(fp) { dup2(fileno(fp), 1); } // prepare the command Q_snprintf(cmd, sizeof(cmd), %s\n, engine-Cmd_Args()); // just some tests puts(Test:); Msg(Cooltest\n); // queue the command engine-ServerCommand(msg); // actually execute the command engine-ServerExecute(); // more tests puts(posttest); Msg(coolposttest\n); // restore everything if we messed with anything if(fp) { // flush to make sure text gets written to file, not console fflush(stdout); fclose(fp); // put stdout back dup2(oldstdout, 1); // and close the duplicate close(oldstdout); flushall(); } When this code executes a command on the server (cvarlist for example), no output is written to the console but there is no relevant output in the rcon.txt file either. The contents of the rcon.txt file are: Test: posttest The tests using Msg() don't write to the file nor does the server command. Nothing is written to the console either, so it looks like the output gets lost somewhere. Why doesn't this work to redirect output of Msg()? I'm testing this in Windows. I'd be surprised if it didn't work in Linux as well since Linux seems to be more compliant with these sorts of things. Does anybody have any ideas or recommendations? -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders -- -omega -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders
[hlcoders] Redirect server command output
This is a multipart message in MIME format. -- [ Picked text/plain from multipart/alternative ] I'm trying to redirect the output of a server command to a file, but I'm having problems. I've come up with the following code (this code is within a ConCommand that I have written): char cmd[2048]; // clear out any pending commands first engine-ServerExecute(); // save the old stdout int oldstdout = dup(1); // redirect stdout to rcon.txt if writable FILE *fp = fopen(rcon.txt, w); if(fp) { dup2(fileno(fp), 1); } // prepare the command Q_snprintf(cmd, sizeof(cmd), %s\n, engine-Cmd_Args()); // just some tests puts(Test:); Msg(Cooltest\n); // queue the command engine-ServerCommand(msg); // actually execute the command engine-ServerExecute(); // more tests puts(posttest); Msg(coolposttest\n); // restore everything if we messed with anything if(fp) { // flush to make sure text gets written to file, not console fflush(stdout); fclose(fp); // put stdout back dup2(oldstdout, 1); // and close the duplicate close(oldstdout); flushall(); } When this code executes a command on the server (cvarlist for example), no output is written to the console but there is no relevant output in the rcon.txt file either. The contents of the rcon.txt file are: Test: posttest The tests using Msg() don't write to the file nor does the server command. Nothing is written to the console either, so it looks like the output gets lost somewhere. Why doesn't this work to redirect output of Msg()? I'm testing this in Windows. I'd be surprised if it didn't work in Linux as well since Linux seems to be more compliant with these sorts of things. Does anybody have any ideas or recommendations? -- ___ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders