a simple file transfer server..
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
the function Writeln does not exist on my man pages... maybe you wrote it and the error is in it. Or it could be that sockfd is not what you want (could you have put the stdout in it?).
And another thing (not related to the networking part): system does not return a string. That means that the output is going to stdout and you are missing it. Which is probably what you are seeing on the screen. If you want to get the output, use popen.
Most likely the networking part is just ok and the problem is the one I described in the paragraph above, but I cant tell for sure since I dont know the code.
Hope this is useful! :)
Getting back to your original question:
Demon_vox is absolutely correct. The server is printing "pwd" to the server's command-line because you're having the server run the program "pwd" ... which outputs to stdout ... the *SERVER'S* "stdout". Duh.
Opening a pipe to the "pwd" command is one solution.
Using "popen()/read()/pclose ()" (which, under the covers, opens the pipes for you) is an equivalent - and much easier to code - solution.
Simply calling "getcwd()", however, is probably the easiest solution.
|All times are GMT -5. The time now is 06:55 PM.|