码迷,mamicode.com
首页 > 系统相关 > 详细

shell script to gg

时间:2015-12-09 19:27:48      阅读:227      评论:0      收藏:0      [点我收藏+]

标签:

 

 

 

==================================================
#!/bin/bash
sqlplus=sqlplus64
username=$1
psswd=$2
filedir=$3
[[ $filedir ]] || filedir="/sandbox/EDF_API_REPO_DIR"
[[ -d $filedir ]] || { echo "mkdir $filedir"; mkdir $filedir; chmod 777 $filedir; }
[[ -d $filedir ]] || { echo "cannot create oracle directory"; exit 1; }   
[[ $username ]] || { echo "Where is user name?" ; exit 1; } 
[[ $psswd ]] || psswd=$username 
echo "create user $username identified by $psswd"; 
sqlcode="
connect sys/111111@localhost:1522/xe as sysdba; \n
set serveroutput on; \n
create user $username identified by $psswd; \n
grant all privileges to $username; \n
grant execute on utl_http to $username;  \n
grant execute on utl_file to $username;  \n
grant execute on utl_smtp to $username;  \n
CREATE OR REPLACE DIRECTORY EDF_API_REPO_DIR as ‘$filedir‘; \n
declare \n
  uzer varchar2(100) := ‘$username‘; \n
BEGIN\n
  uzer := upper(uzer);  \n
  begin \n
     dbms_network_acl_admin.drop_acl(\n
       ‘utl_http.xml‘\n
     );\n
  exception when others then 
    dbms_output.put_line(sqlerrm);
  end;
  dbms_network_acl_admin.create_acl (\n
    acl         => ‘utl_http.xml‘,\n
    description => ‘HTTP Access‘,\n
    principal   => uzer ,\n
    is_grant    => TRUE,\n
    privilege   => ‘connect‘\n
  );\n
  dbms_network_acl_admin.add_privilege (\n
    acl        => ‘utl_http.xml‘,\n
    principal  => uzer,  \n\n
    is_grant   => TRUE,\n
    privilege  => ‘resolve‘\n
  );\n
  dbms_network_acl_admin.assign_acl (\n
    acl        => ‘utl_http.xml‘,\n
    host       => ‘*‘\n
  );\n
  dbms_output.put_line(‘acl created‘ ); \n
END; \n
/\n
show errors;"

echo -e $sqlcode | $sqlplus /nolog

 

shell script to gg

标签:

原文地址:http://www.cnblogs.com/Jeffrey-xu/p/5033766.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!