[Radiance-general] Linux installation

Mark Steven Baker [email protected]
Fri, 19 Jul 2002 08:30:46 -0700 (PDT)


Bruce,

Some comments below on your questions.

There are two styles of shells on most UNIX (and Linux) systems: those
derived from the original bourne shell (sh) which include bash, ksh, etc. 
and those derived from the C shell (csh, tsch, etc.). The difficulty for
many beginners is that these two families of shells support different
syntax for setting variables in the environment along with different
control flow commands.

Under sh or bash, you set an environment variable as follows:
  RAYPATH=/usr/local/radiance/lib  
  export RAYPATH

The first line sets the RAYPATH environment variable only for the current
operating shell. If you start another shell from the current shell, then
the RAYPATH environment variable will not exist. The second line 
exports or sets the RAYPATH variable in the environment so it will be
inherited by other shells. These two commands can be combined into a single
line as follows:

  RAYPATH=/usr/local/radiance/lib; export RAYPATH

The semicolon allows multiple commands to issued on the same command line.
NOTE: make sure the RAYPATH environment variable points to where you
actually installed the radiance lib files.

Normally, this command would be placed in the .profile file located in your
home directory. The .profile file is read when the sh, bash, or ksh shell 
starts.  It acts as an initialization file where you can set all kinds of 
environment variables, change behaviors of the shells, etc. The bash shell 
will also read a .bshrc resource file in your home directory if it exists. 
This .bshrc file is for commands that only the bash shell understands. A
similar .bash_profile file can be used for bash-only startup commands. If
these files don't exist in your home directory, then the system uses some
system-wide files in the /etc (/etc/profile, for example). These system-wide
files should not be changed (except by very experienced administrators).

To set the RAYPATH environment variable and add the radiance bin folder
to your path in your .profile file might look something like the following.
Note comment lines begin with a # character.

# set a RAYPATH if this environment variable does not exist
if [ ${RAYPATH:-""} = "" ] ; then
        RAYPATH=/usr/local/radiance/lib
        export RAYPATH
fi

# add the radiance binaries to the PATH (note we added at front of path)
PATH=/usr/local/radiance/bin:$PATH

# set a MANPATH environment variable if it doesn't exist
if [ ${MANPATH:-""} = "" ] ; then
        MANPATH=/usr/share/man
        export MANPATH
fi

# Add the radiance man pages to the MANPATH
MANPATH=$MANPATH:/usr/local/radiance/man
export MANPATH

If you set these environment variables for bash in the .profile file, then
they will be inherited by any shells that you start (spawn) from this
shell including c shells.

The "set" command will display all of your current environment variables.
You may need to pipe this command through less or more to see all of the
variables if you aren't in anm X window:
  set |less

Note that the SHELL variable is confusing since this variable indicates the
login shell, not the shell that you may be using if you started a csh from
bash.

Now we switch to the C shell side of things. The syntax to set enviroment 
variables in the csh (and tcsh) is different. In this case, there is a 
single command to set an environment variable.

setenv RAYPATH /usr/local/radiance/lib
setenv PATH /usr/local/radiance/bin:$PATH

The "setenv" command will display the environment variables. These commands
could be placed in a .cshrc file in your home directory that is read
whenever a c shell starts. The .login file is read after the .cshrc file
when this is a login script. 

The choice of shells is a personal preference. You will find that most books
on Linux will discuss and provide examples for sh and bash, not csh. So I
would suggest that you stick with bash for the time being. In any case,
you would be better to use tcsh than csh as your csh shell since it
supports a similar syntax for history (executing previous commands again).
Both bash and tcsh support using control-p and control-n or the up-arrow
and down-arrow to move through a list of previous commands. They also
support very similar syntax for editing a previous command line. The
left-arrow and right-arrow move left or right one character at a time,
while the home and end keys move to the beginning or end of the line. The
delete and backspace delete characters from the command line and any
other characters are inserted. Both bash and tcsh support similar syntax
for filename completion. 

Once you have logged into Linux you can start another shell easily (just type
csh or tcsh to start a C shell). This new shell will inherit all of the
environment variables from the previous shell

The radiance developers were familiar with the C shell, so the examples that 
they provide are written using the C shell syntax. 

The command to change your login shell is chsh. If this command is given
by itself, it will prompt you for the shell you which to use for login.
Note that you have to provide the full path to the shell you wish to use.
The following command will list the command shells that Linux knows about
(the command shells listed in /etc/shells):
chsh -l

The chsh program edits the /etc/passwd file in a safe way and changes the
program (command shell) that the operating system runs when you login.

Your choice of scripts for running radiance are a personal preference. Note
that the first line of a shell script file indicates what shell or command is
to execute the commands. Take a look at the rlux or xyzimage shell scripts
located in the radiance bin directory. These scripts begin with the following:

#!/bin/csh -f

This could just as well have been a perl scripti starting with a first line:
#!/usr/bin/perl

Note that shell script files need to be marked as executable (chmod +x) if
you want to be able to just type the shell file name and have them execute.
Otherwise you have to give the name of the file to the shell:
  csh /usr/local/radiance/bin/rlux 

I built and installed radiance from the sources, so ignore the locations
in the examples above for where the radiance files are installed. I
customized my installation so all of the radiance files where placed in
directories under /usr/local/radiance. This likely differs from the
location where these files are placed when installing the Linux binaries
downloaded from LBL.

Regards,
-Steve

Bruce Sounes writes:
[ Charset ISO-8859-1 unsupported, converting... ]
> I have recently installed Suse Linux V8 at home to explore using Radiance in
> its "native" environment. Starting with the Desktop Radiance installation
> under Windows, I am now reasonably confident in setting up scenes, lights
> etc using Cad and a text editor.
> 
> I am finding Linux a bit of a challenge.  How do I set the RAYPATH
> environment variable under the Bourne Again Shell (bash), and how do I set
> it as part of my login? I have discovered that if I change to the c-shell
> (csh) and follow the installation instructions, it works for that session.
> Similarly the animation scripts in the old email archives work under csh,
> but not under bash. Should/Can I set Linux to use the c-shell as standard?
> Is it worth the bother? Can anyone offer advise on the best way to go, or
> refer me to good documentation sites.
> 
> Not being familiar with either language, and because of its cross-platform
> support, I have been reading up on Perl as an alternative for writing
> scripts to use with Radiance. Has anyone used Perl for animations and would
> they be willing to share their efforts? 
> 
> Many thanks 
> 
> Bruce Sounes
> 
> _______________________________________________
> Radiance-general mailing list
> [email protected]
> http://www.radiance-online.org/mailman/listinfo/radiance-general
> 


Steven Baker                      Contributing Editor, Unix Review
(541) 683-5927                    360 East 15th Avenue
[email protected]            Eugene, OR 97401