0

I've got a problem related to write to files.
I've created server/client in c (for Linux, via sockets).
I want the clients to save a log file with all the actions they did. When I open a client and transfer file everything is OK but when I check my server's multi requests support (by creating a bash script that checks it all) I discovered that none of my clients write anything.

Client command is: ./client_prog host port file_to_receive log_file

Script:

cd client1/
./client_prog localhost 22222 file.txt log &
cd client2/
./client_prog localhost 22222 file.txt log &
cd client3/
./client_prog localhost 22222 file.txt log &
#more clients....

each client create log thread and with pipe transferring data, and the log thread write it with fopen(), fprintf() and fclose().

BTW, when I try from two different terminals, it's working fine.
It doesn't make any sense..

Thanks!

Nikolai Fetissov
  • 82,306
  • 11
  • 110
  • 171
Yoav Amir
  • 23
  • 1
  • 3
  • 3
    do you have a copy of `client_prog` in each of the `clientN/` subdirectories? And shouldn't it be `cd ../client2` (from `client1`) if all your `clientN/` directories have the common parent – Anton Kovalenko Jan 22 '13 at 13:42
  • are you passing the full path of the log file when calling your command? – nullrevolution Jan 22 '13 at 14:19

1 Answers1

0

Is that your exact script (or a simplified spinet)?

Are you sure you don't want to do a 'cd ..' prior to trying to move to the other client directories (after the first client)? Cause if your initial 'cd client2' fails, then you'll end up trying to start a client using the same 'file.txt' and 'log' which could cause you some errors?

Jeach
  • 8,656
  • 7
  • 45
  • 58