Return-Path: william@bourbon.usc.edu Delivery-Date: Fri Oct 31 16:20:27 2008 X-Spam-Checker-Version: SpamAssassin 3.2.3 (2007-08-08) on merlot.usc.edu X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.3 Received: from bourbon.usc.edu (bourbon.usc.edu [128.125.9.75]) by merlot.usc.edu (8.14.1/8.14.1) with ESMTP id m9VNKR2N023250 for ; Fri, 31 Oct 2008 16:20:27 -0700 Received: from bourbon.usc.edu (localhost.localdomain [127.0.0.1]) by bourbon.usc.edu (8.14.2/8.14.1) with ESMTP id m9VNWE8H004446 for ; Fri, 31 Oct 2008 16:32:14 -0700 Message-Id: <200810312332.m9VNWE8H004446@bourbon.usc.edu> To: cs551@merlot.usc.edu Subject: Re: fprintf() Date: Fri, 31 Oct 2008 16:32:14 -0700 From: Bill Cheng Someone wrote: > Where will be the HomeDir obtained from the ini file be used ? e.g If the > HomeDir is a/b/n??, does it mean that the log file and the > init_neighbor_list file should be stored in a/b/n?? . Please see: http://merlot.usc.edu/cs551-f08/msgs/bill/313.txt The logfile name should be created in the same manner: char logfile_path[256]; snprintf(logfile_path, sizeof(logfile_path), "%s/servant.log", home_dir); > The HomeDir in all the .ini files is /tmp/final1/n??. Did you check out any of the startup configuration file referenced in the grading guidelines? None of them are in /tmp/final1. > So can we simply hardcode /tmp/final1/n?? for > the init_neighbor_list file & logfile path ? No! You should not hardcode *anything* (well, except when you need to create a temporary file by using mkstemp(), you can hardcode "/tmp" as the directory for temporary files). -- Bill Cheng // bill.cheng@usc.edu On Fri, Oct 31, 2008 at 1:40 PM, Bill Cheng wrote: > Someone wrote: > > > The status.out file should be stored in the current working directory > (where > > the code is being run from and where the executable is) right ? > > That's not the right definition of "current working directory". > The "current working directory" of your program is the > "working directory" of the shell program when you invoke > your program. In your UNIX shell, if you type: > > pwd > > it will print out the current working directory of your shell. > > Let's say that your source and executable are in > /home/somewhere/final/part1. I can run your program as follows: > > cd /tmp > pwd > /home/somewhere/final/part1/sv_node ~csci551b/public/final1/b1-n00.ini > > Then /tmp is your "current working directory". How would you > know? In your main(), you can do: > > char current_working_dir[256]; > > getcwd(current_working_dir, sizeof(current_working_dir)); > > and current_working_dir will be "/tmp". > > > When different nodes try to write to the file, sometimes the file is > blank > > for some nodes...all run the same code ! > > > > What could be the problem ? > > Don't know! Debug, debug, debug! > -- > Bill Cheng // bill.cheng@usc.edu