0

I'm trying to use a command line tool called ccnd. I want to send its log to a file. The documentation of the tool says:

To start ccnd sending output to a log file instead of the terminal, set the CCND_LOG environment variable with the path of the file you want to write. Any existing file with that name will be overwritten.

So here is what I did:

$ CCND_LOG='./ccnd.log'
$ ccnd

But I still see the output of the command line tool in my terminal. How do I make CCND_LOG effective on ccnd?

I am using bash, which seems to be the default setting of my Mac OS X Terminal.

4
  • Are you using tcsh or bash as your shell? By default, Mac OS X uses tcsh, which is a C shell derivative. Commented Mar 16, 2013 at 5:44
  • @JonathanLeffler I am using bash. Commented Mar 16, 2013 at 5:49
  • using the solutions below, does it create a log file (but still echo output to the screen)? Good luck. Commented Mar 16, 2013 at 6:06
  • @shellter The solutions I got so far don't work for me. No log file was created. The ccnd tool is still writing its log in my terminal. Commented Mar 16, 2013 at 6:12

1 Answer 1

3

Either:

$ CCND_LOG="./ccnd.log" ccnd

Or:

$ export CCND_LOG="./ccnd.log"
$ ccnd

The first sets the environment for the command; the second sets the environment until it is changed. All environment variables are also shell variables; not all shell variables are environment variables. Until it is exported, a variable is just a shell variable; once it is exported, it becomes part of the environment.

If you are using a C shell derivative (such as tcsh), you'd have to use the setenv command to create an environment variable; the first variant is not an option with C shell.

% setenv CCND_LOG ./ccnd_log
% ccnd

If you're using bash, either of the first two should set the environment for the duration of the command. Use the export notation. Then run env | grep CCND to check that it is set.

I see that the CCNx Documentation says:

All CCNx programs require that a ccnd be running:

bin/ccndstart

To start ccnd sending output to a log file instead of the terminal, set the CCND_LOG environment variable with the path of the file you want to write. Any existing file with that name will be overwritten.

For a listing of other environment variables that are available (including debug message controls) run:

bin/ccnd -h

Note that you should not ordinarily run ccnd directly, but use the ccndstart script.

(Emphasis added.)

Are you running ccnd or ccndstart?

Sign up to request clarification or add additional context in comments.

8 Comments

Unfortunately neither one works for me. I'm using Mac OS X Shell. Will I need setenv? I think the CCND_LOG environment variable is already created (although it is blank by default). I can see its value by echo $CCND_DEBUG
Yes; by default, tcsh is the shell in a Mac terminal. Then you need the setenv notation; see my update.
The first two solutions don't work for me. The ccnd tool is still writing its log in my terminal instead of in a file.
See the notes added to the answer about using ccndstart and not just ccnd. Do you have permission to write in the directory where you're running the program?
Mac OS X changed the default shell from tcsh to bash many years ago.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.