当前位置: 技术问答>linux和unix
从root切换到另一个用户执行命令,shell脚本怎么写:
来源: 互联网 发布时间:2017-02-18
本文导语: 我想在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:/sbi...
我想在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;
我写了一个如下:
#!/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;
改成
sqlplus / as sysdba
select sysdate from dual;
select sysdate from dual;
exit;
改成
su - oracle