Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Use of host command from scripted SQL

Re: Use of host command from scripted SQL

From: Radoulov, Dimitre <cichomitiko_at_gmail.com>
Date: Fri, 15 Dec 2006 16:29:59 +0100
Message-ID: <029b01c7205d$e43081a0$ba00a8c0@ETP6320>


} I was playing around with SQL*Plus and found that I could include the
} host command in my scripts, being a UN*X person I styarted trying to get
} the result of some simple commands (pwd, ls, grep, etc) back into SQL,
} but got no joy.

You can use shell script/sqlplus combinations, instead of the "HOST" command.

} What I'm trying to do is something like:
}
} DEFINE my_var = HOST pwd;
}
} Or
}
} SELECT (HOST pwd) FROM dual;
}
} Or somesuch... Is there a way to do this?

May be this is not exactly what you're looking for, but you can _read_ the environment of your server process:

SQL> var e varchar2(20)
SQL> set autop on
SQL> exec sys.dbms_system.get_env('PWD',:e)

PL/SQL procedure successfully completed.

E



/app/oracle

SQL> exec sys.dbms_system.get_env('SHELL',:e)

PL/SQL procedure successfully completed.

E



/bin/bash

$ export E="$(ls)"
$ printf "%s;\n" "var e varchar2(100)" "set autop on" "exec sys.dbms_system.get_env('E',:e)" | sqlplus -s / as sysdba

PL/SQL procedure successfully completed.

E



admin
autopasswd
flash_recovery_area
mysql

...

Regards
Dimitre

--
http://www.freelists.org/webpage/oracle-l
Received on Fri Dec 15 2006 - 09:29:59 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US