0

I have created the following test1.csh and test2.csh to debug an error from link_grib.csh which is a .csh script that comes from a climate simulation software package called WRF.

I do not have superuser access on this Linux server. The provided script has run fine for a superuser on the same server so no modification should be needed.

I broke out two simple snippets from link_grib.csh, one involving foreach, and the other involving symbolic link and illustrates the output I am seeing, please see my questions below.

1) Test1.csh

#!/bin/csh
echo ${1}
foreach f ( ${1}* )
end

Output:

[frank@simunec1 20130604_mini]$ ls ./FNL.dat
./FNL.dat
[frank@simunec1 20130604_mini]$ test1.csh ./FNL.dat
./FNL.dat
foreach: No match. 

Question: Why would foreach return no match here?

2) Test2.csh

#!/bin/csh
ln -sf ./FNL.dat GRIBFILE.AAA

Output:

[frank@simunec1 20130604_mini]$ test2.csh
[frank@simunec1 20130604_mini]$ ls GRIBFILE.AAA
ls: cannot access GRIBFILE.AAA: No such file or directory  

// but running the same command outside of .csh script, everything is fine
[frank@simunec1 20130604_mini]$ ln -sf ./FNL.dat GRIBFILE.AAA
[frank@simunec1 20130604_mini]$ ls GRIBFILE.AAA
GRIBFILE.AAA

Question: Why does running the same command outside of .csh script works.

Oded
  • 489,969
  • 99
  • 883
  • 1,009
frank
  • 1,283
  • 1
  • 19
  • 39

1 Answers1

1

At a wild guess, you've got a .cshrc file that's changing the directory.

I'd try putting a -f in the shebang line (#!/bin/csh -f), or invoking the csh script using csh -f <file>.

You can use the -X option which will display commands executed in the startup scripts (the .cshrc files) which could point you in the right direction.

Anya Shenanigans
  • 91,618
  • 3
  • 107
  • 122