Print CD and changes to txt file?

Hello all, I'm working on a honeypot with a server/client TCP and I've run into a problem processing the CD command. When I run the program to test my CD function, parameter char command[ 2048 ] will be "cd .. " to move up 1 level in the directory, but when I call the system to create a txt file from which to save the contents I still get the directory I began with and not the new directory.

If it's not enough code to decipher let me know, don't want to crowd the thread.

Thanks for any help.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
char CD(int newsockfd, char command[ 2048 ]) 
{
	char buff[1000];
	system( strcat( command, " > cd.txt") );
	FILE *file = fopen("cd.txt", "r");//file variable; 

	while(fgets(buff, 1000, file) != NULL)
	{
		send(newsockfd, buff, 1000, 0);				
	}

	fclose(file);  // close the file 
	send(newsockfd, "\n", 1000, 0);
	send(newsockfd, "EOF", 1000, 0);
	return buff[1000];
} 

Last edited on
Topic archived. No new replies allowed.