Script Prepartion in shell
Hi,
I tried to automated Re-Org script Prepartion for tables.
Geneally We check first with Dba_tables to confirm partitions,then dba_tab_partitions, then dbs_tab_subpartitions.
In the same way,We check index also.
I unable to complete above things in shell script.Any suggestions.
{code}
echo "Enter table name:"
read a
export ENV_FILE=/u01/app/oracle/11.2.0.3/product/rdbms/.0411.env
sqlplus -s system/[email protected] << EOF
spool /tmp/columns.sql
select ' Exec Dbms_Stats.Create_Stat_table(Ownname => '''||Owner || ''',Statab => ''Stats_'||table_name||'_30082013'',,TBLSPACE =>''TOOLS'');' from dba_Tables where table_name Like '$a;
select ' Exec Dbms_Stats.export_Stat_table(Ownname => '''||Owner || ''',Tabname => '''||table_name||''',STATTAB =>''STATS_'|| table_name ||'_08022013'',CASCADE => TRUE, STATOWN =>'''||owner||''');' from dba_Tables where table_name Like '$a';
spool off
exit
{code}
Br,
Raj
Hi,
I didn't understand what you are saying.
I plan to do like this.Please check and correct me if anything wrong
Object :
Once executed the first statement,We know that the object is partition or non partition .if the object is non partition,second statment should be executed but no need to execute remaining 3,4 statement.
1,select table_name,partitioned from dba_Tables where table_name='';
2,Select 'Alter table ' || table_owner || '.' || table_name || ' move ;' from dba_Tables where table_name in ('');
3,Select 'Alter table ' || table_owner || '.' || table_name || ' move partition ' || partition_name || ';' from dba_Tab_partitions where table_name='';
4,Select 'Alter table ' || table_owner || '.' || table_name || ' move subpartition ' || SUBPARTITION_NAME|| ';' from dba_Tab_subpartitions where Partition_name='' and table_name='';
INDEX
Once executed the first statement,if the index is non partition,second statment should be executed but no need to execute remaining 3,4 statement.
1,select index_name ,partitioned from dba_indexes where table_name='';
2,select 'Alter index ' || owner || '.' || index_name || ' rebuild;' from dba_indexes where table_name in ('');
3,Select 'Alter index ' || index_owner || '.' || index_name || ' rebuild partition ' || partition_name || ';' from dba_ind_partitions where index_name in ('U_SKUPROJSTATIC_D_DCG_PK');
4,Select 'Alter index ' || index_owner || '.' || index_name || ' rebuild subpartition ' || partition_name || ';' from dba_ind_subpartitions where index_name in ('') and partition_name in ('');
Any suggestions.
Br
Similar Messages
-
I Need to Export in on Report to CSV or HTML this result of two scripts in power shell on Exchange 2010.
Get-Mailbox | Select-Object DisplayName, IssueWarningQuota
and
; Get-MailboxStatistics -server MYSERVER | Select-Object DisplayName, TotalItemSize, Itemcount, StorageLimitStatus, Database, IssueWarningQuota | Export-Csv Reporte.csv -notypeinformationHi,
Please try the command below:
Get-Mailbox -server servername | select-object DisplayName,@{l='TotalItemSize';e={(Get-MailboxStatistics -identity $_.identity).TotalItemSize}},@{l='Itemcount';e={(Get-MailboxStatistics -identity $_.identity).Itemcount}},@{l='StorageLimitStatus';e={(Get-MailboxStatistics
-identity $_.identity).StorageLimitStatus}},@{l='Database';e={(Get-MailboxStatistics -identity $_.identity).Database}},IssueWarningQuota | Export-Csv C:\mbxstatistics.csv -notypeinformation
Regards,
Rebecca Tu
TechNet Community Support -
SQL-Scripts into a Shell script
Hi!
After creating the database on a Linux machine, we need to create our Schema in that database.This Schema has many objects(tables, views,
procs, triggers etc.). So executing each individual script would not be sensible. Is it possible to pack all sql scripts into one shell script and run that one?
Thanks for your feedback/examples/links!If it's one-off task, why not put all of them in a SQL file and run it from SQL* Plus rather than using shell to cause sql plus which will in turn have to call the script?
If it's a recurring task and you insist that you want to do it from Unix shell, you can do something like this:
Place all scripts in a single file and put it under $HOME for ex. (save it as run_all_scripts.sql)
Then write a shell script something like this:
#!/bin/ksh
connect_schema=scott/tiger
sqlplus -s $connect_schema <<EOF
@$HOME/run_all_scripts.sql
EOF
Regards
Venkat -
RMAN script doesnt exit shell after backup
Hi,
I've the following script on AIX 6.1, Oracle 11.2.0.1.0:
export ORACLE_HOME=/oracle/medprod/product/11.2.0/dbhome_1
export ORACLE_SID=MEDPROD
export PATH=$ORACLE_HOME/bin:$PATH
export LOG_DIR=/home/medinous/backup/logs
export LOG_FILE=$LOG_DIR/medprod_daily_backup_`date +%d%m%Y%X`.log
rman target / catalog rman/rman@rman log=$LOG_FILE <<EOF
execute script medinous_daily;
exit;
EXIT;
EOF
and:
printing stored script: medinous_daily
+{+
allocate channel t1 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t2 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
allocate channel t3 type 'sbt_tape' parms 'ENV=(TDPO_OPTFILE=/usr/tivoli/tsm/client/oracle/bin64/tdpo.opt)';
backup format 'medinous_dailybackup_%d_%s_%t' database;
backup format 'medinous_dailyarchbackup_%d_%s_%t' archivelog all not backed up 1 times;
crosscheck backup;
delete noprompt obsolete;
delete noprompt expired backup;
delete noprompt expired archivelog all;
release channel t1;
release channel t2;
release channel t3;
+}+
For some reason, the rman script, scheduled via crontab doesn't exit after successful backup, the process just remain alive, even though there's an explicit exit command at the end.
Any idea?
dulaNo, the script actully executes successfully. The problem is that after executing, the process does'nt die, it doesnt exit rman:
channel t1: finished piece 1 at 28-DEC-10
piece handle=prodarchbackup_PROD_666_738921153 tag=TAG20101228T075233 comment=API Version 2.0,MMS Version 5.5.2.0
channel t1: backup set complete, elapsed time: 00:00:03
channel t2: finished piece 1 at 28-DEC-10
piece handle=prodarchbackup_PROD_667_738921153 tag=TAG20101228T075233 comment=API Version 2.0,MMS Version 5.5.2.0
channel t2: backup set complete, elapsed time: 00:00:03
channel t3: finished piece 1 at 28-DEC-10
piece handle=prodarchbackup_PROD_668_738921153 tag=TAG20101228T075233 comment=API Version 2.0,MMS Version 5.5.2.0
channel t3: backup set complete, elapsed time: 00:00:03
Finished backup at 28-DEC-10
Starting Control File and SPFILE Autobackup at 28-DEC-10
piece handle=c-148294895-20101228-00 comment=API Version 2.0,MMS Version 5.5.2.0
Finished Control File and SPFILE Autobackup at 28-DEC-10
released channel: t1
released channel: t2
released channel: t3
*<< I expect the rman shell script to exit at this point and 'die' >>>>* -
Generate RMAN backup Script using unix shell script
Hello,
Could somebody give me a unix shell script that would generate RMAN script based on some user defined parameters in a config file.
e.g.
rman.conf
CHANNELS=4
USE_CATALOG=Y
DEVICE='sbt_tabe'
etc.,
many thanks,
kamYou can actually encapsulate the RMAN commands inside the shell script.
However if you really want to create a seperate RMAN script file, you can use the unix shell's "echo" command to write set variables to a file.
Thus, for example,
echo "rman target / catalog rman/rmanpassword@crcat" > RMAN_Script.rmn
echo "backup database plus archivelog" >> RMAN_Script.rmn
echo "backup archivelog all" >> RMAN_Script.rmn
creates RMAN_Script.rmn with 3 commands. -
How to submit an input dynamically to an sql script in a shell script
Dear all,
I have a shell script myscript.sh, in that I am running an sql script , say mysql.sql, the sql script prompts for a value, and I have to type that prompted value to run the script. How can I give this value in my shell script itself.
Sample script
#!/bin/bash
echo "script starting at $(date)"
sqlplus apps/apps @mysql.sql
echo "script completed at $(date)"
exit
Regards,
CharanHi,
Please see
$cat sql_para.sh
#!/bin/bash
. .bash_profile
sqlplus -s apps/apps @status $1
$cat status.sql
select status from v$instance where host_name='&1';
exit;$./sql_para.sh TEST
You may also see
http://www.nsa.no/259/shell-scripting-dbas-using-awk-manipulate-oratab
https://communities.bmc.com/communities/docs/DOC-9942
Thanks -
Passing Multiple Parameters to SQL Script from a Shell Script
Hi Friends,
I have SQL script which accepts 6 parameters.
I am calling this from a shell script as shown below:
sqlplus -s ${ORACLE_ID} @${SQLPATH}KORONT_041.sql ${USER_ID} ${PDC} ${item_number} ${KORDC} ${PDCSET} ${last_Updated_in_hours} Out of the six parameters, item_number is not a mandatory parameter.
When i pass all six parameters, there is no issue.
But when i leave item_number blank, i am getting the below error
Enter value for 6:
User requested Interrupt or EOF detected.Based on the error, it seems that the NULL values for item_number is ignored and SQL*PLUS is waiting for one more input from user.
How can i overcome this issue?
Regards,
SreekanthHi,
I am calling the shell script from concurrent program and below is the log file of the concurrent program.
Copyright (c) 1979, 1999, Oracle Corporation. All rights reserved.
KORONT_041_SH module: KORONT - Daily Item Master Update
+---------------------------------------------------------------------------+
Current system time is 29-JUN-2011 10:09:35
+---------------------------------------------------------------------------+
REQUEST_ID: 68510795
USER_ID: 4219
PDC: 85
Item Number:
KORDC: 124
PDCSET: 1100000003
last_updated_in_hours: 24
EMAIL_ID: [email protected],[email protected]
SQLPATH: /e381/oracle/asodev01appl/custom/motont/1.0.0/sql/
RPTDIR: /e381/oracle/asodev01comn/admin/out/ASODEV01_asoprdb2
RPTFILE: o68510795.out
Table truncated.
*Enter value for 6: User requested Interrupt or EOF detected.*
Table truncated.
old 15: AND ic.organization_id = &&4
new 15: AND ic.organization_id = 1100000003
0 rows created.
Input truncated to 9 characters
old 8: AND organization_id = &&4
new 8: AND organization_id = 1100000003
0 rows created.
End of SQL
No record.
+---------------------------------------------------------------------------+
Executing request completion options...
+------------- 1) PRINT -------------+
Printing output file.
Request ID : 68510795
Number of copies : 0
Printer : noprint
+--------------------------------------+
Finished executing request completion options.
+---------------------------------------------------------------------------+
Concurrent request completed successfully
Current system time is 29-JUN-2011 10:09:38
+---------------------------------------------------------------------------+Regards,
Sreekanth -
ASR9000 perl scripting in the shell environment
Hi everybody,
I am writing a perl embedded script in order to get information about pseudowires.
I need to get the output of this ksh command: l2vpn_show -d 0x1 | grep -E "(Group.*XC)"
The problem is that when I execute this command by the shell CLI it works. If I try to make it run by a perl program it faults, probably because the | (pipe) char is not execute.
The line I write is:
my $cli_output = `l2vpn_show -d 0x1 | grep -E "(Group.*XC)"`;
It faults even this command:
my $cli_output = `l2vpn_show -d 0x1 | grep Group`;
Any hint to help me?
Regards
Raffaele Tostiniyou can use perl and ksh scripting and officially supported EEM (with TCL). My idea was not to change to another language but to show that in perl itself it is not straight forward to pipe commands from shell and if there is a need to get specific lines from $cli_output then you parce this variable by using perl like
my $cli = `l2vpn_show -d 0x1` ;
my @lines = split /\n/, $cli;
foreach my $line( @lines ) {
if ($line =~ /Group.*XC/) {
print $line . "\n";
Regards,
/A -
Bash script working in shell, but not in Automator
This script works for me in a bash shell, and adds tags to an mp3.
#!/bin/bash
for file in *.mp3;
do
a=`basename "$file" .mp3 | sed -e 's/.* - //'`
b=`echo "${file%%-*}"`
id3tool \
-t "$a" \
-r "$b" \
"$file"
done
If I put it into Automator (get selected items-->shell script), it doesn't work...
it doesn't give errors, it simply doesn't have any effect, why?
for file in "$@"
do
a=`basename "$file" .mp3 | sed -e 's/.* - //'`
b=`echo "${file%%-*}"`
/usr/local/bin/id3tool \
-t "$a" \
-r "$b" \
"$file"
doneThere's a step ahead, apparently the automator script WORKS, the only problem is that the artist name is "/path/to/mp3/ARTISTNAME", while if I run the script in a bash shell, the artist name is correct and it is "ARTISTNAME", how "basename" output suggests, why?
for file in "$@"
do
a=`basename "$file" .mp3 | sed -e 's/.* - //'`
b=`echo "${file%%-*}"`
/usr/bin/id3v2 \
-t "$a" \
-a "$b" \
"$file"
done -
Run vbs script from maxl shell
Hi -
I created one vbs script (test.vbs) which copy file from one location to another one. I'm calling this vbs script from one maxl script (copy.msh).
Here is the code in copy.msh:
login "$user" "$pw" on "$server";
shell "$(path)test.vbs xx.rul";
When I run copy.msh script from windows command line, I get the window popup message:
"Windows can not open this file test.vbs" ...
Do I have to configure something on my machine to run vbs script? Any help on this would be highly appreciated.
Thank You!Ensure the $path variable is being assigned the correct value. Based on the error you quoted, its not being assigned a value at all.
It would help if you posted your actual code. Pls put the code inside {code} {code} tags for easier viewing.
Robb Salzmann -
Simple bash question: how to script into new shell?
I want to have a script that opens a new terminal and calls some commands. I am to stupid. :oops:
Pink Chick wrote:
*Smack*
This should be ok. I was tired of typing "makepkg foobar", and so I wrote a tiny dirty nautilus script to do that for me. Unfortunately, it worked in the background. Not bad, if you KNOW your package is ok, but in case of errors.
Thank you all.
hmm sounds like an interesting idea... i don't use nautilus myself... but i could see it being cool to double click a PKGBUILD file and have it run makepkg... -
Passing password in an AS script to a shell command
Hi,
I'm posting here based on this discution:
http://discussions.apple.com/thread.jspa?threadID=345269
In my case I want to pass the password to the rsync command. The command I use is on the format:
rsync -vr --size-only ~/Sites/ usernameonserver@serveuraddress:/path/to/the/directory
Normally rsync will ask for a password. How the password and username are passed from AS to terminal (or what is equivalent to)?
it is important to mention that the user and password are not local, but on the remote server.
ThanksHi Steve,
As you've probably gathered, from this post and the other thread you linked to, AppleScript doesn't really offer a straightforward way to run command line tools that require user interaction.
The suggestions NovaScotian offered may work for your rsync dilemma, but I thought I'd mention another option that you might want to investigate for this or other similar problems. There is a command line tool called "expect" that is specifically tailored for automating the running and interaction with other commands that require user responses. See the man page for "expect" for specifics.
Basically "expect" allows you to write a script that controls what other process it launches, what prompts to wait for and what values to feed to the prompts. These expect scripts can be as complex as you need to make them and they can deal with multiple secondary processes if needed. The expect script can sort of act as a "middle-man" between AppleScript and the actual command line tool(s) you want to run. AppleScript runs an expect script, the expect script runs the command you really want to execute and deals with any interactive prompts and finally returns any results back to the AppleScript.
So, getting back to your rsync problem... you could write your AppleScript to call an "expect" script passing it the rsync password. And you would write your expect script to accept the password as one of it's command line parameters. The expect script would then launch rsync, wait for the password prompt and then feed rsync the password you gave it from AppleScript. The expect script would finally return any output or error messages from rsync back to AppleScript.
This may be overkill for your particular problem since rsync apparently gives you other mechanisms for dealing with the password. But in some situations it may be the best or only solution for running interactive command line tools from AppleScript.
Steve -
How do I perform a call to shell script from another shell script
In /jacorb/bin I have to compile some IDL files to java, but I do not know how:
In the terminal window, I am able to run #sh compile.sh
But in compile.sh there is another call to a an idl.sh and a ir.sh at the same line
The error say that it can not find these two files.
What to do...
Br Morten BoMy compile.sh file looks like this:
#!/bin/sh
PATH=/usr/jdk/jdk1.5.0_07/bin:$path;
# my path --> /JacORB/bin/ and /JacORB/lib
idl.sh -ir -d ../src -i2jpackage mortens:com.nokia.m2m.orb.idl.egsmt egsmt.idl
%RESOLVE_JACORB_HOME%
JACORB_HOME=${RESOLVED_JACORB_HOME}
@RESOLVE_JAVA_CMD@
JAVA_CMD=${RESOLVED_JAVA_CMD}
exec "$JAVA_CMD" \
@JACORB_BOOTCLASSPATH@ \
-Djacorb.home="${JACORB_HOME}" \
-Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB \
-Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton \
-classpath "${CLASSPATH}" \
"$@"
And my idl.sh looks like this:
#!/bin/sh
# @DONT_EDIT@
@RESOLVE_JACORB_HOME@
JACORB_HOME=${RESOLVED_JACORB_HOME}
@JAVA_CMD@ -classpath ${JACORB_HOME}/lib/idl.jar:${JACORB_HOME}/lib/logkit-1.2.jar:${CLASSPATH} org.jacorb.idl.parser "$@"
So, what d I have to put in instead of these @@ and $$
I really do not know how to set up pathnames in solaris -
I can't get a simple "do shell script" in AppleScript to work!
Hi All,
I can get simple commands like "do shell script "ls"" or "do shell script "ps"" to work in AppleScript, but I cannot get something like "do shell script "python -V"" to work. (yes, my shell script says: do shell script "python -V" (no double quotes!))
This is driving me nuts!
Can anyone help?
- Jonpython -V appears to direct its output to stderr. Try
do shell script "python -V 2>&1" -
Executing if condition in a sql prompt with in a shell script
Hi all,
i need to write a shell script where i need to execute a sql statement. if the count from the above sql is greater than certain value i need to execute a another sql statement.After some time i need to check the count again using above sql and if the count is less than certain value i need to execute a different sql statement. One more time i need to check the count and then i need to get an email.
Could anyone help me in completing this script
Thanks,Could anyone help me in completing this scriptNot really because "shell script" is OS & Shell dependent & you decided to NOT share these details with us.
Just write a PL/SQL procedure & then you have an OS independent solution!
Maybe you are looking for
-
I have an error opening a pdf document
Everytime I try to open a pdf document while I am online, I just get a little black box with an x in it. My adobe is installed correctly and it is up to date. What do I need to do to fix it? Thanks for the help
-
F-32 transaction TCVIEW table issue
Dear all, In F-32 transaction some columns in line item display got disappeared. We found out that it is because of entries for user .TCADMIN. in table TCVIEW . How it got updated there and how to get rid of them. Regards, Kannan N
-
Hi As we all know Java treat character literals as Unicode characters. I have been studying Unicode and the way they treat characters and I have a doubt which is not specific to Java code but specific to Unicode. Unicode states that each character is
-
Copying production to development
I'm posting this here because, quite frankly, I'm not sure where it should be posted, so forgive my ignorance... Has anyone create a full development installation by using a copy of their production installation? I mean the full suite: BPEL server, B
-
Identifying changes in the custom screen added to Delivery
Hello, I have added a custom screen in delivery transaction(VL02n) at header level. I used BADI LE_SHP_TAB_CUST_HEAD to do that. Now if user comes and enters some data on the custom screen, then goes to menu option Subsequent processing-->Create Tran