質問

I would like my .cshrc file to carry out several commands depending on the host I've logged in to (the .cshrc file is on a disk that is shared by two different hosts).

Let's assume the two hosts are: login1.university.edu and login2.university.edu

I tried this command:

if(hostname == 'login1.university.edu') then
setenv R_LIBS_USER /n/Users/me/R.login1
else
setenv R_LIBS_USER /n/Users/me/R.login2
endif

which doesn't work.

What is the correct syntax?

役に立ちましたか?

解決

Surround the hostname command with backtics to execute it and compare the result.

if(`hostname` == 'login1.university.edu') then
setenv R_LIBS_USER /n/Users/me/R.login1
else
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top