Redirection using csh

I have a csh script which I am using to run a program

  set data   = $argv[1]
  set inmod  = $argv[2]
  set nxz    = $argv[3]

# Remove the file extension .pmod

  set data = ` echo $data | awk 'BEGIN { FS=".dat" } { print $1 }' `
  set inmod = ` echo $inmod | awk 'BEGIN { FS=".vmod" } { print $1 }' `
  set nx = ` echo $nxz | awk 'BEGIN { FS="x" } { print $1 }' `
  set nz = ` echo $nxz | awk 'BEGIN { FS="x" } { print $2 }' `
  set fout = ${data}-${nx}x${nz}-drw

# Run the program tdarwin
 
/nethome/chrisd/Zollo/Chrisd/Tommy-0911/bin/tdarwin base=sunsp.base  \
    data=$data.dat param="P" intp="LIN" inmod=$inmod.vmod            \
    nlay=1 std=on nxp=$nx nzp=$nz npop=60 dtau=0.15 mdacc=0.1        \
    varp=1.0 sigma0=100.0 maxiter=200 maxitertp=10 tol=0.0           \
    outmod=$fout.vmod backup=$fout.bck expl=$fout.exp                \
    vrb=high > $fout.log

I am trying to redirect the output to a file $fout.log but I'm not getting anything.

Trying to do something like below does not work

/nethome/chrisd/Zollo/Chrisd/Tommy-0911/bin/tdarwin base=sunsp.base  \
    data=$data.dat param="P" intp="LIN" inmod=$inmod.vmod            \
    nlay=1 std=on nxp=$nx nzp=$nz npop=60 dtau=0.15 mdacc=0.1        \
    varp=1.0 sigma0=100.0 maxiter=200 maxitertp=10 tol=0.0           \
    outmod=$fout.vmod backup=$fout.bck expl=$fout.exp                \
    vrb=high 2>&1 | tee $fout.log

If you just run:

/nethome/chrisd/Zollo/Chrisd/Tommy-0911/bin/tdarwin base=sunsp.base  \
    data=$data.dat param="P" intp="LIN" inmod=$inmod.vmod            \
    nlay=1 std=on nxp=$nx nzp=$nz npop=60 dtau=0.15 mdacc=0.1        \
    varp=1.0 sigma0=100.0 maxiter=200 maxitertp=10 tol=0.0           \
    outmod=$fout.vmod backup=$fout.bck expl=$fout.exp                \
    vrb=high

Do you get anything written to the screen?

Hi.

If you intend to use csh, you need to know the limitations. In this specific instance, see the very first section of Csh Programming Considered Harmful ... cheers, drl

Yes, I get everything on the screen working fine when I don't redirect.

Shoule be okay, the only thing I can think of is to check what noclobber is set to?

See noclobber in:
Man Page for csh (OpenSolaris Section 1) - The UNIX and Linux Forums

Hi.

In a csh script, what happens when you run:

echo one
echo two 2>&1

Best wishes ... cheers, drl

[quote]
In a csh script, what happens when you run:

echo one
echo two 2>&1

[quote]

No difference at all, because no error message was generated!

If you ran:

tony@tony-laptop:~$ ls -l fred > /tmp/logfile
ls: cannot access fred: No such file or directory
tony@tony-laptop:~$ cat /tmp/logfile

Then the listing of fred (if it had existed) would have gone into /tmp/logfile, that is stdout, file handle 1.
The error message is sent to stderr, file handle 2, allowing the user to see it even though stdout was sent to a log file.

If you then run:

tony@tony-laptop:~$ ls -l fred > /tmp/logfile 2>&1
tony@tony-laptop:~$ cat /tmp/logfile
ls: cannot access fred: No such file or directory
tony@tony-laptop:~$ 

Then the 2>&1 has redirected stderr to stdout, stdout was sent to /tmp/logfile so the error message also goes to /tmp/logfile.

Hi.

I have run the following script "s3" on Linux and Solaris. The string two is never displayed:

#!/bin/csh

ls -l /bin/csh

echo
echo one
echo two 2>&1
echo three

exit 0

producing:

% ./s3

one
three

The point is that "2>&1" does not work in the csh family as it does in the Bourne shell family. What happens is that a file named "1" is created with the content:

% cat 1
two 2

... cheers, drl

Sorry drl I was obviously thinking in Bourne shell mode, have not used C shell in anger since departing from SunOS! I must admit I can't see why anyone would script in C shell, it was a good interactive shell before Korn and Bash came along but it was never very good for scripting!