Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

create dir & file in linux o.s thru pl/sql block

user468Aug 4 2011 — edited Aug 15 2011
HI all
i want to create thru pl/sql block a directory on my o.s , the directory will change according to some parameter
select user_name,user_directory ,company_number 
from mng_companies ;
user_name  user_directory company_number 
-------------------------------------------------------------
M03NAS     /usr/m03nas/     300
M04HGF    /usr/m04hgf/      400
M06JUI     /usr2/m06jui       600
in every directory i need to create a text file that contain the user_name
example:
if i was doing it thru linux for user M03NAS it suppose to be like this
mkdir /usr/m03nas
touch /usr/m03nas/USER_N 
the USER_N need to contain the user name M03NAS
now.
my first question is
is it recommended to run this kind of commands thru the pl/sql? (specially mkdir command) ?
my second question is
if so which is the best way to perform this ?
i have to say that i've already have a pl/sql function that call UTIL Java that runs host command ,
like in this link
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3069633370832
just the difference is that instead of this
create or replace function RUN_CMD( p_cmd  in varchar2)
return number
AS LANGUAGE JAVA
NAME  'MyCommand.RunThis(java.lang.String[]) return integer';
my function return 
create or replace function RUN_CMD_L( p_cmd  in varchar2) return varchar2 
  is
  language java
  name 'MyCommand.RunThis(java.lang.String) return java.lang.String';
it returns all the output as string
like if i have the script like this
i#!/bin/bash 
echo "start the script"
that's what the function will return "start the script",
the wuestion is is there any other way to do this actions that i've mention above ?
i also want to emphasis that all this need to be perform thru the APEX !
Thanks in Advanced
Naama
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 12 2011
Added on Aug 4 2011
13 comments
2,911 views