首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 操作系统 > UNIXLINUX >

从root切换到另一个用户执行命令,shell脚本如何写

2012-04-27 
从root切换到另一个用户执行命令,shell脚本怎么写:我想在root下敲 sh test.sh,test.sh要执行以下步骤,这个

从root切换到另一个用户执行命令,shell脚本怎么写:
我想在root下敲 sh test.sh,test.sh要执行以下步骤,这个bash脚本怎么写?


我写了一个如下:
#!/bin/bash
# Program:
# This program import the 'ZJIF' user.
# History:
# 2010/07/01 HanLiangYuan First release
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin:$ORACLE_
HOME/bin
cd /etc/samba
mv smb.conf smb.confBAK
touch smb.conf
这里不知道怎么办了。。
su oracle 这句好像也有问题,卡死不动了
sqlplus / as sysdba
select sysdate from dual;
select sysdate from dual;
exit;

想要tesst.sh实现的操作如下:

[root@localhost ~]# cd /etc/samba
[root@localhost samba]# mv smb.conf smb.confBAK
[root@localhost samba]#touch smb.conf
然后把下面这段写入smb.conf中;
[global]
workgroup = LinuxSir
netbios name = LinuxSir05
server string = Linux Samba Server TestServer
security = share

[linuxsir]
  path = /opt/linuxsir
  writeable = yes
  browseable = yes
  guest ok = yes
然后执行
[root@localhost samba]# su oracle 
然后执行
[oracle@localhost samba]$ sqlplus / as sysdba
SQL> select sysdate from dual;
SQL> select sysdate from dual;
SQL> exit;







[解决办法]
su oracle 这句好像也有问题,卡死不动了
sqlplus / as sysdba
select sysdate from dual;
select sysdate from dual;
exit;
改成

C/C++ code
su - oracle <<EOFsqlplus / as sysdbaselect sysdate from dual;select sysdate from dual;exit;EOF
[解决办法]
其实touch smb.conf 这句都是多余的

热点排行
Bad Request.