Shell script to run against 1000s dbs
what's should be the things to put in this scripts, like how to connect to different server & connect /as sysdba ; and run .sql ? just trying to understand how these kind of scripts work?
#!/bin/sh
#Pull all entries from your tnsnames.ora file, skipping lines with # ( )
#SQLPLUS to each as sys and show the current date
#This assumes that your SYS password is the same on all instances.
for tns_name in `grep -v -E '#|\(|\)' $TNS_ADMIN/tnsnames.ora | cut -f 1 -d ' '`
do
sqlplus -s sys/sys_pwd@${tns_name} as sysdba <<EOF
set head off pages 0 verify off
select sysdate from dual;
exit;
EOF
done
Hope this helps.
Similar Messages
-
Script to run against ALL AD users in a loop
I am going to do a SharePoint upgrade this weekend from 2010 to 2013.
I need this script to run against every Active Directory user automatically, not just one at a time. How do I get this get this script to do that? I figure I create a pipeline, I just don't know where.
Here is the script:
Param(
[string] $account = $(Read-Host -prompt
"UserAccount")
Add-PSSnapIn Microsoft.SharePoint.PowerShell
foreach ($wa in get-SPWebApplication)
Write-Host "$($wa.Name) | $($wa.UseClaimsAuthentication
#http://technet.microsoft.com/en-us/library/gg251985.aspx
$wa.UseClaimsAuthentication = $true
$wa.Update()
$account = (New-SPClaimsPrincipal -identity
$account -identitytype 1).ToEncodedString()
$zp = $wa.ZonePolicies("Default")
$p = $zp.Add($account,"PSPolicy")
$fc=$wa.PolicyRoles.GetSpecialRole("FullControl")
$p.PolicyRoleBindings.Add($fc)
$wa.Update()
$wa.MigrateUsers($true)
$wa.ProvisionGlobally()
Please help me! Thank you!Hi,
Need to do something like this
$Users=Get-ADUser -filter *
foreach ($User in $Users) {
YOUR SCRIPT
-Identity $Users
YOUR SCRIPT
YOUR SCRIPT
YOUR SCRIPT
Seidl Michael | http://www.techguy.at |
twitter.com/techguyat | facebook.com/techguyat -
Sample shell scripts to run workbooks
Does anybody have some sample shell scripts to run the workbooks?
Your Schedule workbooks thru command line thread contains answers.
-
Sample shell script - to run procedures and shell script
Hi ,
I would like run some procedures in one shell script which passing parameters as username/password@dbname.
1. Execute proce1
2.Execute proce3
3.Execute proc4
Can you please give some script/idea how we will create shell script . I am using SunSolaris Unix operating system.I would appreciate your help.
Regards,
Clarkuser10818198 wrote:
I would like run some procedures in one shell script which passing parameters as username/password@dbname.
1. Execute proce1
2.Execute proce3
3.Execute proc4
At a very basic level, based on the information you have provided, your shell script would be something like this:
sqlplus /nolog <<EOF
connect username/password@dbname
exec proce1;
exec proce2;
exec proce3;
exit
EOFBesides this, you could:
(1) Add the shebang at the top, to specify the shell you are using, e.g. #!/bin/ksh for the Korn shell etc.
(2) Ensure that "sqlplus" is recognized by the shell, by maybe running an "ora_env.sh" script that sets Oracle parameters. More likely, if you are using this Unix account for interaction with Oracle, then you may want to add the Oracle parameter information in your .profile or .bash_profile or .csh_profile etc. in the home directory.
(3) Run a few sqlplus commands right before calling those stored procedures, if needed. For example, if you want to exit from sqlplus (and Oracle) if an error occurs while executing any procedure, then add this -
whenever sqlerror exit 1Thus your script becomes:
#!/bin/ksh
# Ensure that Oracle parameters are set by this point
sqlplus /nolog <<EOF
connect username/password@dbname
whenever sqlerror exit 1
exec proce1;
exec proce2;
exec proce3;
exit
EOF(There are other settings as well; it really depends on your requirements.)
Can you please give some script/idea how we will create shell script . I am using SunSolaris Unix operating system.
How to create a shell script ? Well,
(1) Save the commands shown above in a file, using your favorite text editor. Name the file "my_script.sh" or "<a_better_name>.sh" etc. (or maybe ".ksh" for the Korn shell - it's just a best practice, the shell doesn't really care.)
(2) Make your script executable, like so -
$ chmod 744 myscript.sh(3) And then execute it -
$ ./myscript.sh- You could also execute the script in the current shell (as against a child shell) by doing this after Step (1):
$ . myscript.shHope that helps.
If there are specific questions, then post them here.
isotope -
Shell script for running obiee 11g services in linux
Hi
We have a requirement to create a shell script inorder to run OBIEE 11G services in Linux OS. It would be very helpful and greatly appreciated if any pointer(s)/documentation on this is provided.
Thankswe had run the scripts using nohup "nohup ./startWeblogicServer.sh &" and reopened putty to run other nodemanager and opmnctl scripts, now everything has started and working fine.
Thanks all.. -
Using a UNIX shell script to run a Java program (packaged in a JAR)
Hi,
I have an application (very small) that connects to our database. It needs to run in our UNIX environment so I've been working on a shell script to set the class path and call the JAR file. I'm not making a lot of progress on my own. I've attached the KSH (korn shell script) file code.
Thanks in advance to anyone who knows how to set the class path and / or call the JAR file.
loggedinuser="$(whoami)"
CFG_DIR="`dirname $0`"
EXIT_STATUS=${SUCCESS}
export PATH=/opt/java1.3/bin:$PATH
OLDDIR="`pwd`"
cd $PLCS_ROOT_DIR
java -classpath $
EXIT_STATUS=$?
cd $OLDDIR
echo $EXIT_STATUS
exit $EXIT_STATUSHi,
I have an application (very small) that connects to
our database. It needs to run in our UNIX environment
so I've been working on a shell script to set the
class path and call the JAR file.
#!/bin/sh
exec /your/path/to/java -cp your:class:paths:here -MoreJvmOptionsHere your.package.and.YourClass "$@"Store this is a file of any name, e.g. yuckiduck, and then change the persmissions to executechmod a+x yuckiduckThe exec makes sure the shell used to run the script does not hang around until that java program finishes. While this is only a minor thing, it is nevertheless infinite waste, because it does use some resources but the return on that investment is 0.
CFG_DIR="`dirname $0`"You would like to fetch the directory of the installation out of $0. This breaks as soon as someone makes a (soft) link in some other directory to this script and calls it by its soft linked name. Your best bet if you don't know a lot of script programming is to hardcode CFG_DIR.
OLDDIR="`pwd`"
cd $PLCS_ROOT_DIRVery bad technique in UNIX. UNIX supports the notion of a "current directory". If your user calls this program in a certain directory, you should assume that (s)he does this on purpose. Making your application dependent on a start in a certain directory ignores the very helpful concept of 'current directory' and is therefore a bug.
cd $OLDDIRThis has no effect at all because it only affects the next two lines of code and nothing else. These two lines, however, don't depend on the current directory. In particular this (as the cd above) does not change the current directory for the interactive shell your user is working in.
echo $EXIT_STATUS
exit $EXIT_STATUSEchoing the exit status is an interesting idea, but if you don't do this for a very specific purpose, I recommend not to do this for the simple reason that no other UNIX program does it.
Harald. -
Need Power shell script to run on all databases.
Hi,
I have a stored procedure to generate report, using power shell script want to get all databases, run stored procedure on each database and generate the results as .csv file, output the file with database name (place it on directory) and email .csv
file.
looking for script, can any one help pls?
Naveen| Press Yes if the post is useful.Can you please share with me the codes
Naveen| Press Yes if the post is useful.
Dear N_14
You can have a look on the followings
http://www.csharp-station.com/Tutorial/AdoDotNet/lesson07
http://www.codeproject.com/Articles/415732/Reading-and-Writing-CSV-Files-in-Csharp
https://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage%28v=vs.110%29.aspx
Best Regards
mintssoul -
Automator workflow "run shell script" keeps running. How to stop?
Because i want two instances of dropbox running simultaneously on my Mac, I set up a small automator workflow application. The workflow consist of a simple shell script:
Or in text:
bash
HOME=$HOME/Dropbox-quivertree /Applications/Dropbox.app/Contents/MacOS/Dropbox &
The problem is that once the application runs, or i execute the script from within automator, it just keeps running (i get the little cog in my menubar). Anybody have an idea how to automatically stop after it has launched dropbox?
Thanks!
KimI do not have dropbox on my computer, so I tested using the Calculator application. The solution proposed by Mattis S.F. does work, but his explanation does not hold true in my case. Initially, I successfully tried
HOME=$HOME/Dropbox-quivertree nohup /Applications/Calculator.app/Contents/MacOS/Calculator >/dev/null 2>&1 &
If I remove the “nohup”, the result does not change. Removal of the “/dev/null 2>&1”, however, results in the same problem originally described by Kim van der Leeuw. My guess is the background process has stdout and stderr redirected by default back to the automator. When redirected to /dev/null, the automator no longer waits for the background process to complete. To summarize, change
HOME=$HOME/Dropbox-quivertree /Applications/Dropbox.app/Contents/MacOS/Dropbox &
to
HOME=$HOME/Dropbox-quivertree /Applications/Dropbox.app/Contents/MacOS/Dropbox >/dev/null 2>&1 & -
Power shell script to run a Resuable workflow.
Hi,
We came across a scenario where we want to run a resuable workflow on all List items in a list. I am not sure if this can be acheived through power shell. Can any one please help me to run reusable workflows through power shell script on list items.
Thanks,
SandyHello,
Recently i executed below script for my VS workflow on list items, you can also try same on reusable WF.
Basically you need to use "WorkFlowManager" and "WorkFlowAssociations " to find WF on list and then execute it.
http://www.mysharepointadventures.com/2012/06/start-a-workflow-using-powershell/
http://www.thesysadminhimself.com/2013/09/sharepoint-start-workflow-all-items-powershell.html
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
Unix master shell script to run jobs in parallel with dependency
I need a master shell script which would call the following shell scripts as per below order. Kindly note that if any shell script fails then the master shell script should abort.
Level 1 PRODUCTS
SP_ROST_DLY_STG_lD
SP_ROST_DLY_ITG_lD
After Level 1 completes run below two shell scripts in parallel:
Level 2 SP_IDL_EDGE_CON_POSTN_STG_Ld , SP_IDL_EDGE_ACCT_POSTN_STG_LD
After Level 2 completes run below shell scripts as per the seqeunce and in parallel:
Level 3 SP_IDL_EDGE_ACCT_STG_LD , SP_IDL_EDGE_CONT_STG_LD
SP_IDL_EDGE_ACCT_STG_VAL , SP_IDL_EDGE_CONT_STG_VAL
SP_IDL_EDGE_ACCT_ITG_Ld , SP_IDL_EDGE_CON_ITG_Ld
After Level 3 completes run below shell scripts as per the seqeunce and in parallel:
Level 4 SP_IDL_EDGE_CONT_POSTN_ITG_LD , SP_IDL_EDGE_VISITS_LD
SP_IDL_EDGE_ACCT_POSTN_ITG_LD , SP_IDL_EDGE_VISITS_DTL_LDcan i avoid using set -e and use some other method so that if there is an error in previous job then the next job is not triggered.Sure, but it is ugly.
The below is not the only way to do this...
Wrap every place you start another script with:
$ if ! MYSCRIPT; then
echo Script MYSCRIPT failed. >&2
exit 1
fibut the wrapper for parallel scripts is even worse:
$ MYSCRIPT &
$ MYSCRIPT_JOBNO=$!
$ MYSCRIPT2 &
$ MYSCRIPT2_JOBNO=$!
$ MYSCRIPT_STATUS=`wait ${MYSCRIPT_JOBNO}`
$ if [ ${MYSCRIPT_STATUS} -ne 0 ]; then
echo Script MYSCRIPT failed. >&2
exit 1
fi
$ MYSCRIPT2_STATUS=`wait ${MYSCRIPT2_JOBNO}`
$ if [ ${MYSCRIPT2_STATUS} -ne 0 ]; then
echo Script MYSCRIPT2 failed. >&2
exit 1
fi
...Now, doesn't a simple 'set -e' look much better? -
LoginHook Shell Script not running?
I have a very simple login shell script (open http://pathtowebsite.local) that I have set as a LoginHook. When running the script from the Terminal, it opens the website, as expected. However, on login it appears that something happens, the menu bar flashes and disappears until you click on something, but the website doesn't open. The permissions are set properly, and it is executable. The script is located in the global /Library folder in a folder I created called Management, though I also tried putting it in the /Users/Shared directory in case it was an access issue.
Any ideas on what I might do to resolve this issue? I can't seem to get it to actually kick off at user login like it should.The LoginHook environment is minimum. There is NO PATH
pwd: /
id -a: uid=0(root)
gid=0(wheel)
egid=80(admin)
groups=0(wheel),
1(daemon),
2(kmem),
8(procview),
29(certusers),
3(sys),
9(procmod),
4(tty),
5(operator),
80(admin),
20(staff)
$1: thelogin_person'susername
printenv:
PWD=/
SHLVL=1
SECURITYSESSIONID=449a3aa0
_=/usr/bin/printenv
Notice, no PATH, no USER environment variables, just about nothing as an environment.
So there is no way for the LoginHook to find the 'open' command.
Try changing your script to /usr/bin/open -
Shell script to run PL/SQL Program
hai,
i have problem in returning values from PL/SQL procedyre back to Shell script which calls the procdure.can anyone please suggest a model shell script to handle this
ThankyouSQL> create or replace function disp_mess
2 return varchar2 is
3 begin
4 return('Hello World');
5 end;
6 /
Function created.
SQL> select disp_mess from dual;
DISP_MESS
Hello World
SQL> exit
Disconnected from Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
With the Partitioning option
JServer Release 8.1.7.4.0 - Production
$ cat disp_mess.sh
MESS=`sqlplus -s scott/tiger << !
set head off
set pages 0
select disp_mess from dual;
exit
! `
echo $MESS
$ disp_mess.sh
Hello World
$Paul -
Greetings,
I am new to powershell and scripting and would like to create a powershell script to do the following to XML files.
I would like to change the data received in XML files that contains special Nordic characters: such as
ä, Ä, é, ö, Ö, ü, Ü, and ß respectfully.
The file names that gets drop to me come in with the following naming convention: C54ABC_111120140500_1, C54ABC_111120140500_2, C54ABC_111120140500_3, C54ABC_111120140500_4 all the way to C54ABC_111120140500_12.
By automating the script, I would like the script to look into a directory containing these files and access the data within it and change the the data that has the special characters to the English Dictionary character equivalent.
e.g. ä for a, Ä for A, é for e, ö for o, Ö for O, ü for u, Ü for U, and ß for ss.
Once that step is complete. I would like to rename the file from C54ABC_111120140500_1.xml to C54ABC_111120140500_1_rctf.xml (adding an additional 5 characters to the end of a file that was corrected) if the file did not need any correction then renaming is
not needed.
the working directory (Source and destination) will remain in the same location. e.g. C:\Temp\
Currently I was able to come up with the following, however I am stuck when it comes to the renaming part since, it requires "IF and Else" statments .... I think.
$Source = "C:\Temp"
$Destination = "C:\Temp"
$regex33 = "\*.xml"
(Get-Content $regex33) |
ForEach-Object {$_ -replace "ä", "a" -replace "Ä", "A" -replace "é", "e" -replace "ö", "o" -replace "Ö", "O" -replace "ü", "u" -replace "Ü", "U" -replace "ß", "ss"}
#Rename-Item -NewName {$_.name -replace -whatif}
Your Assistance and Expertise is greatly appreciated.
Thank you in advance KC.Hi KC
You could try something like this.
Let me know how you get on and if you've any questionds.
cheers, Tim
$Source = 'C:\Temp'
Set-Location $source
$xmlFiles = Get-ChildItem -Path $source -Filter *.xml
ForEach ($xmlFile in $xmlFiles)
$content = Get-Content -Path $xmlFile.FullName
$renameFile = $false
Switch -Wildcard ($content) {
'*ä*'
$renameFile = $true
$content = $content -creplace 'ä', 'a'
'*Ä*'
$renameFile = $true
$content = $content -creplace 'Ä', 'A'
'*é*'
$renameFile = $true
$content = $content -creplace 'é', 'e'
'*ö*'
$renameFile = $true
$content = $content -creplace 'ö', 'o'
'*Ö*'
$renameFile = $true
$content = $content -creplace 'Ö', 'O'
'*ü*'
$renameFile = $true
$content = $content -creplace 'ü', 'u'
'*Ü*'
$renameFile = $true
$content = $content -creplace 'Ü', 'U'
'*ß*'
$renameFile = $true
$content = $content -creplace 'ß', 'ss'
If ($renameFile)
$newFileName = "$($xmlFile.BaseName)_rctf.xml"
$content | Out-File -FilePath $xmlFile.FullName -Force
Rename-Item -Path $xmlFile.PSChildName -NewName $newFileName -
Capturing Users with running sql in shell script after every 10min
Hi All,
we have a strange prob. of database crash, therefore decided to check what users do when OS/DB crashes,
i need your input in RUNNING/SCHEDULING such a script which gathers all active users with running SQL and append in a logfile so that we are aware of what happened when DB/OS Crashed.
i can run this run a query from V$SESSION,V$SQL, and V$PROCESS but i need your input writing such a SHELL Script and scheduling can run by CRON.
Regards.Here ya go.
(Assuming you want a script to run against one sid)
script:
#!/bin/ksh
# Set environment
. $HOME/.profile
export ORACLE_SID=your sid
sqlplus <<! > /some_report_file
/ as sysdba
sql you want to execute here*
exit
cron entry:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * /your/script/name/here > /dev/null 2>&1 -
How to run a java class from a shell script with passing arguments
hi,
I have a jar with all the required classes. I was using ant to run the classes i needed.
But now i want to use a shell script to run the class, also the class accepts some arguments so when script is run it should accept arguments.
So can any one tell me how to set class paths, jar location and call the required class from shell script or batch file with passing arguments to it.
Thanks in advance.Let's say that the order of arguments is as below
1. Jar file name
2. Classpath
Your shell script would look like this
java -cp $CLASSPATH:$2 -jar $1 I am assuming that your jar file has the required main-class entry in its manifest. Note that $1...$9 represent the arguments to this shell script.
The same goes for a batch file
java -cp %CLASSPATH%;%2 -jar %1
Maybe you are looking for
-
Does anyone else experience this problem? When I try to edit photos in the photo app and in the camera app I try to crop them and the system will randomly crash. Giving me either a circle ticking logo on a black screen or the system will reboot
-
SQL Developer and TOAD connection.
Hi, I am able to see the DDL script for tables using TOAD, but NOT using SQL Developer (2.1.1). Same user, pass, and tnsname file. They use same tnsname.ora file on my computer. I set basic and TNS connection for SQL Developer. The connection is from
-
Hi All, I want to convert from decimal (5, 2) to decimal (3,0) in data services. if anybody knows please let me know with syntax.
-
Is there anyone with knowledge fo the internal workings of the JVM? I was wondering, is a static call in Java automatically synchronized? I can't find a resource with a satisfying answer, so I thought I try it here. I was having some performance prob
-
Itunes store will not open after downloaading iTunes 8.1.0.2
I was owrking on my husbands iPod shuffle, after downloading new songs from itunes, I decided to download the new version of iTunes. Well after everything was downloaded, I tryed to go and download a show for my ipod, and the itunes store tryed to op