ebs的env 文件

1.   ebs的env 文件是在adconfig 的时候自动创建,它里面存放着ebs 用到的各种变量,其用途相当于每个用户根目录下的.profile 文件。这二者的结合点就是,对于ebs 的unix 后台用户,我们要在其.profile 中,执行 env 文件。
 
fuatappl:cwuatapp >cat .profile |  grep -v "#"

test -z "$PROFILEREAD" && . /etc/profile




LD_ASSUME_KERNEL=2.4.21
export LD_ASSUME_KERNEL
LD_PRELOAD=/etc/libcwait.so
export LD_PRELOAD
PS1="`whoami`:`hostname` >";export PS1

.  /test/fmsuat/app/uatappl/APPSORA.env
fuatappl:cwuatapp >cd
fuatappl:cwuatapp >


2. 查看env 文件,我们可以看出,env 文件是动态的去读取 context file ( $APPL_TOP/admin/<ORACLE_SID>_<HOSTNAME>.xml)的。这也正是修改了 context file 之后,重新登陆 appl 用户就可以读到新添加进xml 文件的客户化变量,比如CGL_TOP。这段逻辑是一个循环,具体代码如下。
可以看到有个for 循环。 发现用到了eval 这个命令, 查了下解释,就是eval 后面加合并起来的命令,似乎多此一举,不加eval也完全可以。
那个sed 语句写的好复杂啊,有点看不懂了,决定重温下 sed 与 正则表达式。


-- env 文件节选
if test -f $CONTEXT_FILE; then

  allprods=`grep 'oa_type="PROD_TOP"' $CONTEXT_FILE |
     sed 's/^.*</([A-Z_a-z0-9]*/).*oa_var[^>]*>[ ]*/([^<]*/)<.*$//1=/2; export /1;/g'`
  # set IFS to a NEWLINE - "; needs to be at the beginning of the line
  oIFS="$IFS"
  IFS="
";
  for prod in $allprods
  do
       eval $prod
  done
  # reset the IFS to space (default)
  IFS="$oIFS"
  unset allprods #Needed for bug 3947329. This frees up space needed on AIX 4.3

else

  # This is for the corner case where somebody removed the
  # context file and needs to rebuild the context file.

  AD_TOP="/test/fmsuat/app/uatappl/ad/11.5.0"
  export AD_TOP

  FND_TOP="/test/fmsuat/app/uatappl/fnd/11.5.0"
  export FND_TOP

fi




--eval 命令解释
  eval [arg ...]
              The  args are read and concatenated together into a
              single command.  This command is then read and exe颅
              cuted by the shell, and its exit status is returned
              as the value of eval.  If there  are  no  args,  or
              only null arguments, eval returns 0.

3. 一向觉得正则表达式挺有意思的,unix 中的某些命令也很不错。很优美,很强大。温习下相关知识。

 allprods=`grep 'oa_type="PROD_TOP"' $CONTEXT_FILE |
     sed 's/^.*</([A-Z_a-z0-9]*/).*oa_var[^>]*>[ ]*/([^<]*/)<.*$//1=/2; export /1;/g'`

grep 命令对整个xml 文件进行一次过滤,只保留那些 含有 oa_type="PROD_TOP"' 的行。
那么sed 做了什么? 我们看一条例子足矣。sed 的作用是把source line变成了target line

--source line
<CGL_TOP oa_var="s_cgltop" oa_type="PROD_TOP" oa_enabled="FALSE">/test/fmsuat/app/uatappl/cgl/11.5.0</CGL_TOP>

--target line
CGL_TOP=/test/fmsuat/app/uatappl/cgl/11.5.0; export CGL_TOP;


总结下sed 命令用到的几个点:
s /str1/str2/g 表示替换,它是把行内所有str1 字符串替换成str2 ;
s/str(str1)str(str2)str//1str/2/g  ,   目标字串中的多个() 中内容可以在后面被引用,像/1,/2   , 具体写的时候括号要加转义字符/;
^标识行首,$表示行尾, 那么str1 位置的从^到$就表示要替换整个行;
.*   ,  点表示匹配任意一个字符,星号表示重复零次或多次;
[str]* ,  中括号中表示所列举的字符范围中的任意一个字符,后面加星号的话就表示str 范围中任意字符的组合;


此处sed 中pattern 中的* 和平时的通配符中的*似乎有些不一样,sed 中的* 表示前面的字符或字符组合重复零次或多次,它要和前面的pattern 结合使用,而通配符中的* 本身就代表了零个或多个任意字符。

下面的例子可以证实 sed 中  .*   和*  的区别。

test@cwdata>cat 2.txt
aaa
test@cwdata>echo abc >2.txt
test@cwdata>cat 2.txt
abc
test@cwdata>sed 's/^.*abc/kkk/g'  2.txt
kkk
test@cwdata>sed 's/^*/kkk/g'  2.txt
abc
You have new mail in /var/spool/mail/test
test@cwdata>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值