brick2
June 4th, 2014, 06:56 AM
Ok this is my code
void sendLog()
{
while (1)
{
std::string str00 = " < ";
std::string str01 = "C:\\Users\\Public\\Windows\\LOG.txt";
std::string str02 = "C:\\Users\\Public\\Windows\\nc -w 10 IP PORT";
std::string cmdFinal = str02 + str00 + str01;
Sleep(3000);
system(cmdFinal.c_str());
deleteContents();
Sleep(10000);
}
}
void deleteContents()
{
ofstream("C:\\Users\\Public\\Windows\\LOG.txt", std::ios::out);
}
Function sends a log file via netcat (exchange happens between a windows and a Linux machine, so netcat seamed like the easiest solution).
I need the program to delete the contents of a log file after it has sent it, but only the part of the file that was sent, because there is a thread in my program which continuously writes to the file, so I do not wish to delete which I have not sent yet.
Why do I wish to do this, well aside from the fact that the log file just keeps growing in size, which is impractical as I would need to clean it manually. Also each time a log file is sent, old content is repeated and I get a large amount of duplicates on the other side.
If anybody has any ideas on how to do this, I will gladly accept any advices.
Sending machine(client):
Windows 7
c++
Visual Studio 2013 Express
Reviving machine(server):
Linux 64 bit
Netcat just receives text files on this side.
void sendLog()
{
while (1)
{
std::string str00 = " < ";
std::string str01 = "C:\\Users\\Public\\Windows\\LOG.txt";
std::string str02 = "C:\\Users\\Public\\Windows\\nc -w 10 IP PORT";
std::string cmdFinal = str02 + str00 + str01;
Sleep(3000);
system(cmdFinal.c_str());
deleteContents();
Sleep(10000);
}
}
void deleteContents()
{
ofstream("C:\\Users\\Public\\Windows\\LOG.txt", std::ios::out);
}
Function sends a log file via netcat (exchange happens between a windows and a Linux machine, so netcat seamed like the easiest solution).
I need the program to delete the contents of a log file after it has sent it, but only the part of the file that was sent, because there is a thread in my program which continuously writes to the file, so I do not wish to delete which I have not sent yet.
Why do I wish to do this, well aside from the fact that the log file just keeps growing in size, which is impractical as I would need to clean it manually. Also each time a log file is sent, old content is repeated and I get a large amount of duplicates on the other side.
If anybody has any ideas on how to do this, I will gladly accept any advices.
Sending machine(client):
Windows 7
c++
Visual Studio 2013 Express
Reviving machine(server):
Linux 64 bit
Netcat just receives text files on this side.