Chinaunix
标题:
想通过一个shell,登陆不同平台主机
[打印本页]
作者:
caixicheng
时间:
2013-12-13 15:53
标题:
想通过一个shell,登陆不同平台主机
我有一台loginserver,负责所有用户登录
环境中有两种不同的平台,SunOS和Linux
使用csh
由于两种不同平台软件使用环境不同,需要source不同的cshrc文件
我尝试利用uname,分别可以显示Linux和SunOS,然后根据反馈,做一个统一的.cshrc文件,比如匹配的是SunOS,就source cshrc_so,请各位帮忙看看,我用if搞不定。
作者:
惟吾无为
时间:
2013-12-13 16:04
if [ "$(uname -s)" == "Linux" ]; then echo linux; else echo other; fi
linux
复制代码
作者:
caixicheng
时间:
2013-12-13 16:11
回复
2#
惟吾无为
我的跟你差不多,但是linux可以执行,而solaris执行不了,必须要手动source,貌似他不知道else
作者:
q1208c
时间:
2013-12-13 16:16
回复
3#
caixicheng
试着用 一个 “=” 看看.
作者:
caixicheng
时间:
2013-12-13 16:24
回复
4#
q1208c
在solaris下,用sh -x .cshrc 提示syntax error at line 8 :'end of file' unexpected
贴一下我的:
if ( “`uname -s`” == "SunOS" ) then
source ~/cshrc_so
else if ( “`uname -s`” == "Linux" )then
source ~/cshrc_lin
endif
作者:
q1208c
时间:
2013-12-13 17:00
回复
5#
caixicheng
if ( “`uname -s`” == "SunOS" ) then
source ~/cshrc_so
else if ( “`uname -s`” == "Linux" )then
source ~/cshrc_lin
endif
复制代码
试着不用 else if 看看.
if ( “`uname -s`” == "SunOS" ) then
source ~/cshrc_so
endif
if ( “`uname -s`” == "Linux" )then
source ~/cshrc_lin
endif
复制代码
作者:
zooyo
时间:
2013-12-13 17:12
提示:
作者被禁止或删除 内容自动屏蔽
作者:
caixicheng
时间:
2013-12-13 17:19
回复
6#
q1208c
一样结果。
作者:
caixicheng
时间:
2013-12-13 17:19
回复
7#
zooyo
还是 提示syntax error at line 9 :'end of file' unexpected
作者:
zooyo
时间:
2013-12-13 17:21
提示:
作者被禁止或删除 内容自动屏蔽
作者:
caixicheng
时间:
2013-12-13 17:32
回复
10#
zooyo
开始我这个文件只有8行,没有第九行??
作者:
zooyo
时间:
2013-12-13 17:37
提示:
作者被禁止或删除 内容自动屏蔽
作者:
q1208c
时间:
2013-12-13 17:53
回复
9#
caixicheng
或许是有没有闭合的 if end if 之类 的吧?
作者:
caixicheng
时间:
2013-12-14 09:40
回复
12#
zooyo
嗯,应该是格式的问题,我在solaris下,手动输入一份新的文件,可以自动source了~
作者:
caixicheng
时间:
2013-12-14 09:41
回复
13#
q1208c
谢谢你,已经可以了!
作者:
q1208c
时间:
2013-12-16 09:27
回复
15#
caixicheng
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2