Re: Use of host command from scripted SQL

  • From: "Radoulov, Dimitre" <cichomitiko@xxxxxxxxx>
  • To: "oracle-l" <oracle-l@xxxxxxxxxxxxx>
  • Date: Fri, 15 Dec 2006 16:29:59 +0100

} 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


Other related posts: