link_grib.csh foreach: No match

Having problems running the WRF Preprocessing Sysmte (WPS)?

link_grib.csh foreach: No match

Postby frankliu81 » Wed Jun 05, 2013 3:56 am

I have created the following test1.csh and test2.csh to debug an error from link_grib.csh.

I do not have superuser access on this Linux server. The provided script has run fine for a superuser.

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

Code: Select all
#!/bin/csh
echo ${1}
foreach f ( ${1}* )
endOutput:


[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

Code: Select all
#!/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.

Thanks.
frankliu81
 
Posts: 4
Joined: Wed Jun 05, 2013 3:49 am

Re: link_grib.csh foreach: No match

Postby frankliu81 » Wed Jun 05, 2013 10:20 pm

I got my answer from the programming forum stackoverflow.

Basically, I have a .cshrc file that's changing the directory, that is why link_grib.csh foreach fails.

The suggestion given istry putting a -f in the shebang line (#!/bin/csh -f), or invoking the csh script using csh -f <file>.

The -f flag tells the shell that you want a fast startup, which means it won't read your .chsrc file (which is good if you plan on sharing the script with anyone else).

I suggest link_grib.csh takes this change to avoid other users running into the same issue, which can be rather obscured to trackdown. Thanks.
frankliu81
 
Posts: 4
Joined: Wed Jun 05, 2013 3:49 am

Re: link_grib.csh foreach: No match

Postby yayafuture » Mon Apr 17, 2017 3:40 pm

Hi, I met the same problem, so I wonder do you mean add -f in the link_grib.csh?
I tried this but still get the error. Do I need to do something like source this csh file? Thank you.
yayafuture
 
Posts: 3
Joined: Mon Apr 17, 2017 3:35 pm


Return to Runtime Problems

Who is online

Users browsing this forum: No registered users and 4 guests