i'm trying to create a simple file transfer program using C sockets..
i need to print the server's present working directory(PWD) in the client's prompt, when client input the word "pwd"
i have written the following coding for that.. but the pwd is printed in the server's prompt , instead of the client's prompt
Code:
//code in the str_echo.c in SERVER
.......
.......
else if(strcmp(arg1,"pwd")==0)
{
int pwd;
pwd=system("pwd");
snprintf(line,sizeof(line),(char*)pwd);
}
else if(strcmp(arg1,"ls")==0)
{
int ls;
ls=system("ls");
snprintf(line,sizeof(line),(char*)ls);
}
.........
......
n=strlen(line);
Writen(sockfd, line, n);
can someone help me out plz..