How to use Operating System Commands while using define in sqlplus
How to use Operating System Commands while using define in sqlplus . The Host OS is Linux
define report_name=PROD_${host date "+%b"}.html
The above is not working.
The output should be
define report_name=PROD_JAN.html
Regards,
DB
of course I was talking nonsense: the problem here is the mixing of bind variables and DEFINE variables.
With the following changes the script should work (the conditions for begin_interval_time are perhaps not what you want):
variable snap1 number
variable snap2 number
variable rptname varchar2(20)
begin
SELECT min(snap_id) into :snap1 FROM dba_hist_snapshot WHERE CAST(begin_interval_time AS DATE) >= SYSDATE-1;
SELECT max(snap_id) into :snap2 FROM dba_hist_snapshot WHERE CAST(begin_interval_time AS DATE) >= SYSDATE-1;
end;
col file_name_value new_value report_name noprint
select 'PROD_'|| to_char(sysdate,'MON') || '_' || to_char(sysdate,'DD') file_name_value from dual;
define report_type = 'html'
define num_days=2
define begin_snap=:snap1
define end_snap=:snap2
@@?/rdbms/admin/awrrpt.sql
Similar Messages
-
How to execute operation system commands by using TSQL without enabling xp_cmdshell.
Hi Experts
Looking for advise if one can use operation system commands using TSQL without enabling xp_cmdshell.
actually using xp_cmdshell requires sysadmin privs which I am unable to provide (directly or using proc) to a user but the user needs some operating system commands to execute for file manipulation from sql server session. Please share your thought.
Best Regards
khalil>but the user needs some operating system commands to execute for file manipulation from sql server session
See article here
http://www.mssqltips.com/sqlservertip/2014/replace-xpcmdshell-command-line-use-with-sql-server-agent/:
"Problem
I need to run something from the command-line, but based on best practices xp_cmdshell has been disabled. The task that needs to run is an internal process that will originate from within SQL Server. Is there a way to do this without using xp_cmdshell?
Solution
The use of xp_cmdshell is generally frowned upon and is now recommended to be disabled, unless it is absolutely necessary. There is a solution that works around this restriction via the use of SQL Server Agent.
Wherever SQL Server is installed, SQL Server Agent is installed with it (except for SQL Express). SQL Server Agent has the ability to run job steps which invoke the command shell. And in the case that the job is owned by a member of the sysadmin fixed server
role, the job will execute as the service account under which the SQL Server Agent is running. "
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014 -
How to call Operating System commands / external programs from within APEX
Hi,
Can someone please suggest how to call Operating Systems commands / external programs from within APEX?
E.g. say I need to run a SQL script on a particular database. SQL script, database name, userid & password everything is available in a table in Oracle. I want to build a utility in APEX where by when I click a button APEX should run the following
c:\oracle\bin\sqlplusw.exe userud/password@database @script_name.sql
Any pointers will be greatly appreciated.
Thanks & Regards,Hi Guys,
I have reviewed the option of using scheduler and javascript and they do satisfy my requirements PARTIALLY. Any calls to operating system commands through these features will be made on the server where APEX is installed.
However, here what I am looking at is to call operating systems programs on client machine. For example in my APEX application I have constructed the following strings of commands that needs to be run to execute a change request.
sqlplusw.exe user/password@database @script1.sql
sqlplusw.exe user/password@database @script2.sql
sqlplusw.exe user/password@database @script3.sql
sqlplusw.exe user/password@database @script4.sql
What I want is to have a button/link on the APEX screen along with these lines so that when I click that link/button this entire line of command gets executed in the same way it would get executed if I copy and paste this command in the command window of windows.
Believe me, if I am able to achieve what I intend to do, it is going to save a lot of our DBAs time and effort.
Any help will be greatly appreciated.
Thanks & Regards, -
How to execute Operating System commands from Stored procedure.
Any help on how to execute Operating System commands from stored procedures will be appreciated.
Nanditha.Search the forums for 'External Procedure' and you will find example code that has been posted before.
-
Unzip file using operating system command in file/ftp receiver adapter
Hi,
I'm wonderdering how to unzip a zip-file in the receiver file/ftp adapter. I know it is possible to do it using the 'Operating system command' feature, but somehow the command I use seems to be ignored! (I'm using SP14, unix).
The command I entered is quite simple: unzip %F (also tried the %f, but i guess it doesn't really matter wich on I use).
Is it possible that I'm unzipping to another directory than the one i expect? the unzip should be performed to/in the current directory, and assumingly current directory is the one stated in the 'Target Directory', right?
Hope someone can clearify this issue for me.
Best regards,
DanielHi Daniel,
It seems to me also, that the files are being unzipped to a different location than what you are expecting. The OS command might getting executed in some default location(i am trying to fnd that out)on the server and not in the target directory of the channel(It seems logical to me)....
If you have time...pls try this out & see whether this would help...
Have a shell script written with the following commands in them
cd <path to target directory>
unzip $1(filename from the channel)
and in the OS command in the Channel give....
<absolute path to the .sh file> %F
Thanks,
Renjith. -
How to Run Operating System Command Before/After Message Processing SAP PI
Hi,
We are trying to execute multiple commands via "Operating System Command Before/After Message Processing".
When we use single command say for example cp or mv (copy or move) the commands get executed fine.
eg: cp %F /var/opt/data/outbound/Test/Dummy.txt
/this works fine/
when we club commands together or try to redirect the outputs of commands, none of the commands get executed.
eg:
cp %F /var/opt/data/outbound/Test/Dummy.txt ; rm %F
or
wc -l %F > /var/opt/data/outbound/Test/Dummy.txt
Is it possible to execute multiple commands or redirect the output of commands without using a shell script? The PI server we are working on iis hosted on UNIX environment.Hi Harleen,
try like this
cp %F /var/opt/data/outbound/Test/Dummy.txt ; rm %F
instead of semicolon try this
(1) &
command1 & command2
Execute Command1 and then execute Command2
(2) &&
command1 && command2
Runs the command2 only when command1 doesn't Complete successfully
(3) ||
command1 || command2
Runs the second command if the first command had an error
(4) ()
(command1 || command2) || (command3 & command4)
Defines the order in which commands are to be executed
Regards
Suraj -
How to: execute operating system commands from PL/SQL
System: IBM pSeries AIX
Oracle: 11g Enterprise
Is there a quick way to execute operating system commands from PL/SQL?
Without creating a JAVA class....
I need to execute a Loader script.
I want to do this from within PL/SQL.
I need to to do 4 things.
Three require SQL scripts.
The fourth is SQL*Loader.
The usual way is with a UNIX script calling 3 SQL scripts and one Loader control file.
Is there way to do all this from within ONE PL/SQL SCRIPT ??
Just let me know.Is there a quick way to execute operating system commands from PL/SQL?
NO
Without creating a JAVA class....
I need to execute a Loader script.
I want to do this from within PL/SQL.
WHY ON EARTH, such action will create a new connection and become a resource hog?
I need to to do 4 things.
Three require SQL scripts.
The fourth is SQL*Loader.
The usual way is with a UNIX script calling 3 SQL scripts and one Loader control file.
Which is perfect for the purpose.
Is there way to do all this from within ONE PL/SQL SCRIPT ??
Just let me know.
NO, there is NOT. Nor should there be. Why create unstable ineffcient Mickey Mouse systems, glued together by hacking?
Sybrand Bakker
Senior Oracle DBA -
Using operating system command on file receiver comm.channel
Hi,
I pepared a XI 3.0 message generating .txt file.
I must append content of this file to the and of the file with same name but different extension(.bak extension).
I know it is achieved with copy name.bak+name.txt it appends txt file to the .bak file.
My problem is: How can i supply name of .txt file to use as name of .bak file?
How can i do that?
Thanks./usr/sap/SID......./../../../Server0
Put the java program there.
Regards
Ravi Raman -
How to call operating system commands?
Can we call OS commands from JAVA?
I am trying to call lpr/lp commands from JAVA.
Can anybody guide me where to search for this information.
Thanks in advance
SriniThanks for you all for this information. I will try this....Your information greatly helped me to go forward...
-
Run operating system command for sender File adpter (NFS)
Hi All,
iam doing a file to RFC scenario, using 'Run operating system command' in sender file adapter to change the file name while archiving (after processing completed).
I mention OS command like this:
sample_server\scripts\Test\Rename.bat"
Rename.bat file calls a 'perl script' code.
when i run interface, could see below statement in adapter log ->
"Execute OS command "
sample_server\scripts\Test\Rename.bat"
but the script was not run and file name was not changed.
Please advice what could be the problem?
Does this mean script executed successfully?
Do i need install perl software on XI server, even perl script (.bat file) is executing on sample_server?
Thanks in advance..
Regards,
RajeshHi,
Just check the following URL and give it a try again :-
Executing Unix shell script using Operating System Command in XI
Hope this info Helps..
Regards,
Aditya -
Operating system command in file adaptor
Hi,
I am doing file to Idoc scenario, can i use the Operating system command in file adaptor to compress the file at FTP server and decompress the file at IE. I dont know is it possible and if yes then how or is there any other way to handle the big files as the network speed is very low.
Any clues!!!!!!!!!!!
Thanks in advance
Regards
SwatantraHave a look into these threads - they seem to have the solution u need (i havnt tried it though)
Unzip file using operating system command in file/ftp receiver adapter
How to zip and unzip xml files dynamically by XI -
Execute external operating system command
Hi Friends,
I have a requirement to run a script file with extention '.PL' on the application server using ABAP.
i have sample how to run it in XI.
XI3.0 provides a very simple way of handling this using the "Operating System Command" in the File Adapter.
I post my output file in the following folder,
/usr/sap/sapout/test/
The shell script is available in the following path,
/usr/sap/bin/convert.pl
The figure below explains as to how we call the shell script using "Operating System Command".
File Acess parameters
Target Directory = /usr/sap/sapout/test/
File Name Scheme = TestOutput.txt
Processing Parameters
File Construction Mode = Add Time Stamp
File Type = Binary
Operating System Command = /usr/sap/bin/convert.pl %F
I have to do the same thing in ABAP as it has been done for XI as mentioned in the above example.
My operating system is UNIX.
If any one can give me a sample it would be really helpful to me.
Thanks in advance,
Arundhathi.Hi Arundhati,
You can run operating system commands from ABAP.
e.g. If you want to change UNIX right for any file, you can use following code.
lv_ucomm = 'chmod a+rwx 123.txt'.
CALL 'SYSTEM' ID 'COMMAND' FIELD lv_ucomm.
whatever command you provide in Field parameter ( lv_ucomm in the above case ), ABAP run that command at operating system level.
In your case, you can provide command in lv_ucomm to run script at operating system level.
Hope it will help you.
Regards,
Naren -
What is Operating System commands in Adapter Configuration??
Hi Frnds,
When we will use Operating system commands Option in Adapter Configuration??
Regards,
RajHi,
Go through this blogs..
/people/michal.krawczyk2/blog/2005/08/17/xi-operation-system-command--error-catching
/people/sameer.shadab/blog/2005/09/21/executing-unix-shell-script-using-operating-system-command-in-xi
When we will use Operating system commands Option in Adapter Configuration??
http://help.sap.com/saphelp_nw04/helpdata/en/0d/00453c91f37151e10000000a11402f/content.htm
Go through this link some experts discussions:
Run Operating System Commands
How to run Operating system command in receiver JDBC Adapter
Hope this info is useful to you..
Thanks,
Satya Kumar.. -
Executing operating system command within trigger or procedure
Hello
Can some one help me out as how to execute operating system command (unix or windows ex.. stop,start,cc,del or copy etc...) in a trigger or procedure.
My requirement is, if some predefined error occure then listener listener should be stopped automatically.
Thanks in advance
kvssHere is some code to tell you how to do:
First a small Java program that taker a string as a parameter and executes it as an os-command
import java.lang.Runtime;
import java.lang.Process;
public class Commands extends Object {
* Constructor
public Commands() {
// On NT the command should be like this "cmd /c del c:\temp\readme.txt"
// exec execute('cmd /c del c:\temp\readme.txt');
public static void execute (String cmd ) {
try {
Process p = Runtime.getRuntime().exec(cmd);
try {
p.waitFor();
catch (java.lang.InterruptedException intex ) {
intex.printStackTrace();
System.out.println("Return = "+ p.exitValue());
System.out.println(" Done ...");
catch ( java.io.IOException iox) {
iox.printStackTrace();
===================end of java ====
Use loadjava to load it into the database and create a pl/sql wrapper around the java code.
See the manual about loadjava details.
Log in to sqlplus as SYSTEM and create a role for this purpose e.g. 'JAVA_ROLE'
and exec the following as SYSTEM or SYS to make sure the user has the the needed privs.
dbms_java.grant_permission('JAVA_ROLE','SYS:java.io.FilePermission','<<ALL FILES>>','read,write,execute,delete');
dbms_java.grant_permission('JAVA_ROLE','SYS:java.lang.RuntimePermission','writeFileDescriptor',null);
dbms_java.grant_permission('JAVA_ROLE','SYS:java.lang.RuntimePermission','readFileDescriptor',null);
and you're done. -
Operating System commands in FTP adapter
Hi
I have a requirement to use "Operating System Command" option in the Sender/Receiver side File Adapter.
And in help.sap.com they have brief notes on this.
http://help.sap.com/saphelp_nw04/helpdata/en/bc/bb79d6061007419a081e58cbeaaf28/content.htm
When I tried to execute some valid DOS commands like MKDIR,RENAME etc it didn't work at all.
But process has been sucessfully completed without any error!!!
System : XI 3.0 SP 11
Can anyone has any inputs on this ? Pls share me some ideas with example. Is there is any limitations on this feature?
Note: When I tried to give invalid commands hfjkhfkasdjfh,asdjdhas etc, still it is not giving any error!!. Still my File Adapter as well as entire process is successfully completed.Hi,
A couple of cautionary notes.
The OS command is executed after the file has been processed, e.g. read successfully by a sender adapter or created successfully by a receiver adapter.
The file name processed can be accessed using %f in the OS command.
The OS command must include the full directory path, or XI will assume the current directory which may not be where your command resides.
Regards,
Bill
Maybe you are looking for
-
Itunes sent email that said I had to change username from aol account. I have logged out, logged in again and no cue to change this pops up. I have attempted 3 different times to get help and each time, someone tells me to do the SAME EXACT THING T
-
How can I re-play the tutorials in iwork?
I am new to Apple and am enjoying the experience thus far. My only unanswered question is how can I re-play the tutorials that popped up the very first time I opened an application? i.e. The first time I opened "Keynote" a window opened that gave me
-
Error message to the launch of a SPARQL query well trained in Java
Hello, I am not if it is a compatibility problem between JENA ARQ and got the message that I sometimes not consistently (at least I can not reproduce !!!) so it is very difficult to correct at least to understand and find a solution? (Anyone have a s
-
How to change maintenance powershell script via GPO?
Per suggestion reposted from here: http://social.technet.microsoft.com/Forums/windowsserver/en-US/6eece9d6-a524-48aa-8e64-7554f0ec9b31/how-to-change-maintenance-powershell-script-via-gpo?forum=winserverGP Posted at http://answers.microsoft.com/en-us/
-
needs a 1080P HD Webcam for my macbook pro for video blogs that my company wants me to start doing from my computer.