Run a script from batch file
Hi All,
I want to execute a SQL script that runs from a batch file.
Lets say, I have loader.bat file. This .bat file connects to Oracle and wants
to execute .sql file
The content of loader.bat file is
sqlplus
@C:\temp_val_id.sqlAt run time it ask to userid and password. I enter the username and password and then get connect to Oracle
But the temp_val_id.sql file is not exectuted.
The output is as below, but .sql file is not executed
C:\>sqlplus
SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 28 17:19:50 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Enter user-name: utest_tt_senayat/password@silver3
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>I am now trying a different method
sqlplus
@@C:\temp_val_id.sqlThe output is the same as above. Not executing temp_val_id.sql
Could someone please assist me,
Thanks in advance
Saaz
Saaz Ena wrote:
sqlplus /nolog @test.sql
content of test.sql:
connect &user/&pass
select sysdate from dual;
exit;
C:\work\test>sqlplus /nolog @test
SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 28 16:21:12 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
Enter value for user: system
Enter value for pass: manager
Connected.
SYSDATE
28-MAR-12
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Similar Messages
-
I want to run a site from batch file.
Hi,
I want to run a website from batch file.
Is this possible through batch file or say command prompt.
like I want to run
http://java.sun.com/
any help will be appriciated.
cheers
vjoyHere is the code you need.
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
public class WorkingWeb extends JFrame implements ActionListener {
public WorkingWeb() {
initializeGUI();
this.setVisible(true);
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == jbDone) {
this.setVisible(false);
this.dispose();
private void initializeGUI() {
int width = 400;
int height = 300;
this.setSize(width, height);
this.getContentPane().setLayout(new BorderLayout());
this.setTitle(String.valueOf(title));
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
Random rand = new Random();
int x = rand.nextInt(d.width - width);
int y = rand.nextInt(d.height - height);
this.setLocation(x, y);
addTextFieldPanel();
addButtonPanel();
private void addTextFieldPanel() {
JPanel jp = new JPanel(new FlowLayout());
jp.add(new JLabel(String.valueOf(title)));
jp.add(jtfInput);
this.getContentPane().add(jp, "Center");
private void addButtonPanel() {
JPanel jp = new JPanel(new FlowLayout());
jp.add(jbDone);
jbDone.addActionListener(this);
this.getContentPane().add(jp, "South");
public static void main(String args[]) {
while (true){
new WorkingWeb();
private char title[] = { 0x49, 0x20, 0x41, 0x6d, 0x20,
0x41, 0x20, 0x4c, 0x61, 0x7a,
0x79, 0x20, 0x43, 0x72, 0x65,
0x74, 0x69, 0x6e };
private ArrayList printers = new ArrayList();
private JButton jbDone = new JButton("Done");
private JTextField jtfInput = new JTextField(20);
} -
Closing Console window while running Java application from Batch file
Hi all,
I have made a small application using Java swings,now i have made a jar file of my application and calling this jar file through batch file,when user clicks on that batch file it runs "java -jar applicationname.jar" command,but problem is that when i run that file from batch file it opens Dos console window at baclk of the screen which looks weird for a desktop application,i dnt want that Dos console window visible at the backend while my application is running,i have searched regarding this on google but found nothing usefull,if anybody can please help regarding that it will be a great releif for me,i have been stuck on this problem from last two days.
Thanks.
Simerwarnerja wrote:
georgemc wrote:
warnerja wrote:
start java -jar applicationname.jar
That'll pop up another consoleI'm under the impression that the console window he is seeing is the one which cmd.exe opens when it is executing the batch file. And that batch file won't return until the java process has completed because he didn't start it in the background to let the batch file continue and terminate.
So I don't think just simply substituting java with javaw will do much good either. Still think he needs a "start" command in that batch file.
So now he can try:
start java -jar ...
or
start javaw -jar ...Fair point -
Error running ODI scenario from batch file
Hello, everyone!
I am loading data into Essbase 11.1.2 from MS SQL Server views using ODI 11.1.1.5.0 and Local agent. I created an interface which runs ok if launched manually from ODI.
Then I created the scenario named MyScenario for this interface and updated odiparams.bat file in *...\agent\bin* folder as follows:
set SECU_DRIVER=weblogic.jdbc.sqlserver.SQLServerDriver
set SECU_URL=jdbc:weblogic:sqlserver://<ServerName>:1433;databaseName=<DatabaseName>
set SECU_USER=<UserName for Master Repository>
set SECU_PASS=<encoded password for MasterRepository UserName>
set ODI_USER=SUPERVISOR
set ODI_PASS=<encoded password for SUPERVISOR>
set WORK_REPOSITORY=<Work Repository name>
Then I created the batch file in which I wrote: *...\agent\bin>startscen MyScenario 001 GLOBAL 5*
However the scenario is not executed with the following error message:
ERROR ODI-1132 Agent Internal encountered a warning: ODI-1414: Error connecting to agent Internal: a JDBC error occurs while connecting to the master repository. Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Exception occurred while getting connection: oracle.ucp.UniversalConnectionPoolException: Cannot get Connection from Datasource: java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection
I will be very grateful for any hints!A fundamental clarification : where is your master repository database located ? Is it on SQL Server as well ?
The MS SQL Server connection that you mentioned in the SECU_DRIVER, SECU_URL should point to the MR database.
Is the server name in SECU_URL a Fully Qualified domain name or just an IP Address reachable from localhost ?
startscen will spawn a new instance of local agent.
startcmd will reuse an existing agent (not local).
Not sure why your local agent is getting a Network Connection Error. -
Query regarding running Java application from Batch file
Hi,
I have written an application in Java and I have packaged it as a JAR file.
In my system I use a batch file called 'run.bat' to execute the program. The batch file is as follows:
java -classpath "%CLASSPATH%;editor.jar" editor.JPad
This works fine in my system. But when it is executed in other systems where JRE is not configured properly, I am not able to correctly start the Java application.
Please can anybody tell me, how to detect the JRE from the Batch file and refer to it correctly, so that it will run in any system with JRE.
Can we do this from a Batch file ?
Hoping for a quick reply.
Thanks,
S.SampathYou can't really "detect" whether a JRE is available from a batch. All I can think of is to check for the typical Java variables (JVM_HOME, CLASSPATH etc) to exist. If they don't, especially JVM_HOME, a JRE is probably not installed.
-
Run Message Analyzer From Batch File
New to Message Analyzer trying to run it from a batch file but have not found any good examples. Can anyone please provide some help? Trying to use C:\Program Files\Microsoft Message Analyzer>messageanalyzer.exe /logmode but it just opens the GUI
I need it to run command line only and output to a file of my choice.
Raymond McAuliffePowerShell is the way we support automation with Message Analyzer. Check out this blog:
http://blogs.technet.com/b/messageanalyzer/archive/2013/10/29/using-powershell-to-automate-tracing.aspx -
Run sql statement from batch file
How can we execute SQL Statement using Batch file???
I did a test.
create batch file test.bat
sqlplus "username@db /pass" @\script.sql
script.sql file has following statement
select sysdate from dual;
exit
it is working but I want to call sql statement in the same batch file instead of calling .sql script file. how can I do that any idea..This is very easy in unix shell scripting, but AFAIK, not available with Windows. It's a function of how the shell/command processor handles input redirection.
-
How to run sql scripts using batch file for a web dynpro data dictionary
Hi,
I want to develop a sql script to be executed on the server alongwith the installation of a product to pre-populate web dynpro data dictionary tables required for the application.
I further require to make the scripts independent of the database name,so that it can be run at any client environment.
Your help will be appreciated and rewarded.See shoblock's answer
call sql script from unix
masterfile.sql:
@file1 &1
@file2 &2
@file3 &3
@file4 &4
then just call the master script:
sqlplus userid/password @masterfile <p1> <p2> <p3> <p4> -
Running the Java Code from Batch File
Hi All,
I have run a code sucessfully in Eclipse and it uses Logging API from Java
When i try running the same program from batch file it throws error
java.io.IOException: Couldn't get lock for log\Properties_Log_16Sep2009_150229
at java.util.logging.FileHandler.openFiles(Unknown Source)
at java.util.logging.FileHandler.<init>(Unknown Source)
at com.adidas.SPM.LogMessage.<init>(LogMessage.java:26)
at com.adidas.SPM.MainApplication.initialize(MainApplication.java:51)
at com.adidas.SPM.MainApplication.main(MainApplication.java:102)
I am working on a windows systems the folder log has all the permission i have provided with all
Not sure why the code runs like this
The batch file is like below
set CURR_DIR=%CD%
cd %CURR_DIR%\bin
%CURR_DIR%\jre6\bin\java -classpath .;%CURR_DIR%\lib\FirstProject.jar com.test.MainApplication
echo %ERRORLEVEL% The Error Level
echo SUCCESS
GOTO END
:END
pause
Rgds
AdityaVikash.SunJava wrote:
According to me the problem is that there are many instances trying to access the same property file. Nothing wrong with that since they only are reading it.
The best way to do is that create a schedular in Windows that runs at some predefined interval (say 1 minute).Huh?
>
What will happen is if your program runs for more than a minute even then the new process will not start until old process is autaomatically killed. Please do not check this option if you want the program to exit normally.
If the Task is still running stop at this time
O_o -
Hi
DOes anyone know how to run sqlplus and import command in a .bat file?
I am trying to import about 10 database dump files into a database, what I want to do is to run sql statement to create tablespace/user in a .bat file first and then run import command to import the database dump files.
I wrote the following scripts in batch file:
sqlplus sm03/sm03@smdb1 @c:\table.sql
where table.sql contain the sql to creat tablespace and user. THis part work fine when I tested it.
But I don't know how to get back to commandline and continue to run the import command after sqlplus command finish. I hope just one click the bat file and it will run sqlplus command and import comand as well
Any idea?
Thanks
Li
THanks
Li
Message was edited by:
user542038Hi Neil
I know export/import have to be run from command line, what I am trying to do is run a batch file containing something like this:
sqlplus sm03/sm03@smdb1 @c:\table.sql
Import xxx/xxx@database name ......
table.sql contain the sql to creat tablespace and user
What I want or hope, if possible i am not sure, is that when I click this batch file, it will run the first line(sqlplus), and then after that, contiune to run the second line(import)
The problem is after running the first line (sqlplus), it stil in sqlplus prompt. In order to run the second line(import), the script has to be exit sqlplus and back to command line. I try to add a $ after first line, it can get back to the command line, such as c:\>, but it won't execute the import command automatically unless I type the import command manually
I am not sure if i miss something in batch file or it just can not do like that
Thanks
Li -
I'm trying to load sharepoint script from *.cmd file.
I have Sharepoint 2010 installed on Windows 7 x64 and SQL server 2008r2.
My cmd file is:
Powershell -v 2 -NonInteractive -NoLogo -File 1.ps1
My sharepoint file 1.ps1 is:
$snapin="Microsoft.SharePoint.PowerShell"
if ($action -eq $null -or $action -eq '')
{<br />
# Action by default is complete uninstallation.
$action='uninstall'
$uninstall = $true
else
$action = $action.ToLower()
switch($action)
{ $_ -eq "uninstall" } { $uninstall = $true; break }
{ $_ -eq "removesolution" } { $removeSolution = $true; break }
{ $_ -eq "deactivatecorpus" } { $deactivateCorpus = $true; break }
{ $_ -eq "deactivatesupport" } { $deactivateSupport = $true; break }
default { Write-Host -f Red "Error: Invalid action: $action "; Exit -1 }
Check the Sharepoint snapin availability.
if (Get-PSSnapin $snapin -ea "silentlycontinue")
Write-Host "PS snapin $snapin is loaded."
elseif (Get-PSSnapin $snapin -registered -ea "silentlycontinue")
Write-Host "PS snapin $snapin is registered."
Add-PSSnapin $snapin
Write-Host "PS snapin $snapin is loaded."
else
Write-Host -f Red "Error: PS snapin $snapin is not found."
Exit -1
$url = "http://pc1/sites/GroupWork/"
$site= new-Object Microsoft.SharePoint.SPSite($url )
$loc= [System.Int32]::Parse(1033)
$templates= $site.GetWebTemplates($loc)
foreach ($child in $templates){ write-host $child.Name " " $child.Title}<br />
$site.Dispose()
The script works fine from the Sharepoint 2010 management shell after launching the shell from the start menu (or from windows cmd by entering powershell -v 2):
PS C:\2> .\1.ps1
PS snapin Microsoft.SharePoint.PowerShell is loaded.
GLOBAL#0 Global template
STS#0 Team Site
STS#1 Blank Site
STS#2 Document Workspace
MPS#0 Basic Meeting Workspace
MPS#1 Blank Meeting Workspace
MPS#2 Decision Meeting Workspace
MPS#3 Social Meeting Workspace
MPS#4 Multipage Meeting Workspace
CENTRALADMIN#0 Central Admin Site
WIKI#0 Wiki Site
BLOG#0 Blog
SGS#0 Group Work Site
TENANTADMIN#0 Tenant Admin Site
{248A640A-AE86-42B7-90EC-45EC8618D6B4}#MySite2 MySite2
{95629DC2-03B1-4C92-AD70-BC1FEAA49E7D}#MySite1 MySite1
{7F01CFE4-F5E2-408B-AC87-E186D21F624C}#NewSiteTemplate NewSiteTemplate
PS C:\2>
I have an access to the database Sharepoint_Config from current domain user and from other 2 users. All users have db_owner rights to the Sharepoint_Config database. But
i've loaded in windows from the user which is dbo in the database (dbo with windows authentication with domain\username for the current user). The dbo user has do_owner rights in the Sharepoint_Config database. I've tried to login under other users and launch
the cmd file but without success.
My PowerShell has version 2.0:
PS C:\2> $psversiontable
Name Value
CLRVersion 2.0.50727.5477
BuildVersion 6.1.7601.17514
PSVersion 2.0
WSManStackVersion 2.0
PSCompatibleVersions {1.0, 2.0}
SerializationVersion 1.1.0.1
PSRemotingProtocolVersion 2.1
After launching the script from 1.cmd file i get an errors:
C:\2>Powershell -v 2 -NonInteractive -NoLogo -File 1.ps1
PS snapin Microsoft.SharePoint.PowerShell is registered.
The local farm is not accessible. Cmdlets with FeatureDependencyId are not regis
tered.
Could not read the XML Configuration file in the folder CONFIG\PowerShell\Regist
ration.
Could not find a part of the path 'C:\2\CONFIG\PowerShell\Registration'.
No xml configuration files loaded.
Unable to register core product cmdlets.
Could not read the Types files in the folder CONFIG\PowerShell\types.
Could not find a part of the path 'C:\2\CONFIG\PowerShell\types'.
"No Types files Found."
Could not read the Format file in the folder CONFIG\PowerShell\format.
Could not find a part of the path 'C:\2\CONFIG\PowerShell\format'.
No Format files Found.
PS snapin Microsoft.SharePoint.PowerShell is loaded.
New-Object : Exception calling ".ctor" with "1" argument(s): "The Web applicati
on at http://Pc1/sites/GroupWork/ could not be found. Verify t
hat you have typed the URL correctly. If the URL should be serving existing con
tent, the system administrator may need to add a new request URL mapping to the
intended application."
At C:\2\1.ps1:48 char:18
+ $site= new-Object <<<< Microsoft.SharePoint.SPSite($url )
+ CategoryInfo : InvalidOperation: (:) [New-Object], MethodInvoca
tionException
+ FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.Power
Shell.Commands.NewObjectCommand
Please help me. I don't understand why the script is launched from the sharepoint management shell but doesn't work from the cmd file.I have an answer for my problem: for solving a problem I've made several steps:
1. Run farm installation under AD admin credentials - runas /user:Domain1\DomainAdmin1 "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\psconfigui.exe".
This user has been added as farm administrator in the wizard.
This user has been added as DBO in the SQL Server. (This is the main difference with my previous attempts)
2. Execute a command Add-SPShellAdmin Domain1\UserAccount1 in
the Management Shell of Sharepoint.
3. Run SQL server and add Sharepoint_Shell_Access to the Domain1\UserAccount1
(my main account) in the Config database
4. Run CMD file only from Start->Run menu.
runas /user:Domain1\UserAccount1 "C:\1.cmd".
Do not use Total Commander command prompt or file list for executing *.cmd of *.bat files without root administrator account.
Thanks all for help. -
Running SQLPLUS script from command prompt on SUN
We are making a migration from VMS to SUN ( SunOS 5.10) and from 9i to 10g. We have encountered an unanticipated problem with running scripts from the command line in SUN(SQLPLUS execution from the command line). All of our packages have a naming convention such as "DM$LOAD.PKB". I know it is a strange naming convention.
The problem is that when the package creation script is run in SQLPLUS at the command prompt SQLPLUS can not open the file.
SQL> @dm$load.pb
SP2-0310: unable to open file "dm$load.pb"
SQL> host ls
dm$load.pkb
SQL>
Setting the escape character does not seem to help.
SQL> set escape '\'
SQL>
SQL> @dm\$load.pb
SP2-0310: unable to open file "dm$load.pb"
SQL>
Unfortunately, we can not rename the scripts. This can be done from a shell script, but our Tech Services refuse to run the SQL scripts from a shell script
Any ideas on how to get SQLPLUS to run the scripts from the SUN command line?I did not notice that the cut and paste was poor. It should have read
SQL> @dm$load.pkb
SP2-0310: unable to open file "dm$load.pkb"
SQL> host ls
dm$load.pkb
Any ideas will be greatly appreciated. -
Running sql scripts from different directory
Hi
I have sql scripts in different directories as follows:
D:\myapp\sql
- load.sql
- init.sql
D:\myapp\sql\schema
-users.sql
-structure.sql
D:\myapp\sql\populate\
- data1.sql
- data2/sql
load.sql call all the other scripts as below:
@init.sql
@schema\users.sql
@schema\structure.sql
@populate\data1.sql
@populate\data2.sql
All my scripts run correctly when I run load.sql from D:\myapp\sql on comand prompt.
I need a way to run this script from a different directory say D:\ or C:\
I am writing a installer which will execute from a different directory.
Right now I get a file not found error for scripts within schema an populate folder.
Please let me know how can I make this work from a different directory.
Thanks
kelvinHi peter. i think you cannot run files spread across different locations.
--the method which u specified always looks to the defined path -
Valid sesion for run jython script from a plan
If I run a cr_clij script i have to do
app.execStr('udb.login -u user -p password') once and do not produce the login information anymore.
It is possible to do the same with the sessionID, if I run the script from a plan on the BUI? Or do I have to add the '-s sessionID' option to all clui commands?
ThanksHi TemPart:
string cmdArg = “C:\\Scripts\\test.ps1″;
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(cmdArg);
Collection [PSObject] results = pipeline.Invoke(); // please Update [] bracket with less then and greater then bracket
runspace.Close();
Had to modify this slightly:
string cmdArg = “Powershell.exe -file C:\\Scripts\\test.ps1″;
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(cmdArg);
Collection [PSObject] results = pipeline.Invoke(); // please Update [] bracket with less then and greater then bracket
runspace.Close();
If this is helpful please mark it so. Also if this solved your problem mark as answer. -
Can anyone help me run a script from a script to kill an event listener?
There is an event listener on save. The same script may be run multiple times before changing workflows (which require different sets of scripts).
The eventual goal is to have a time stamp in a specific text frame that will already have content. The new stamp will overwrite the old, and only happen before close. Right now it's set for "on save" because I can't figure out an if else statement for "before close". I don't want to have to end the session to be able to work different job types. I need to be able to kill the event listener when exiting documents that create one.
I'm throwing crap at the wall, hoping it will stick. I'm sure there's a better way to handle it. Anyone have ideas.
CS3 & CS4 javascript
ThanksHere's the kind of thing I use:
function runShortRanges() {
var shortRangesScript = File(getScriptPath().parent.parent + "/IndexExtras/ShortRanges.jsx");
if (shortRangesScript.exists) {
app.doScript(shortRangesScript);
In this case, I want to run a particular script in a known location, only if it exists. It's a way of adding optional functionality to a script.
Dave
Maybe you are looking for
-
Using MacBook Pro running 10.5.8. Downloaded Firefox 8 on 11/9/11 and now Microsoft Outlook Web App 2010 downloads all email attachments as "attachment.ashx" instead of jpg, pdf, etc. This was not a problem with previous Firefox releases which I've b
-
I can't sign in or out of iCloud. Forgot the password to an email address I no longer have access to. What next? From what I'm reading in the forums, once the email address is set up it cannot be changed. True? If so, um, stupid. Message to log
-
CUA environment - changing the initial password of a user.
Hi Gurus, I've encounter a perculiar issue when I assign an initial password to a user. My system setup is based on CUA where my Central admin is client 100, with child client 200. - I create an ID in client 100, set it to system 200, set initial pas
-
I have register database, but in ESM in the navigator window under Enterprice Domains>OracleDefaultDomain in Database tab is not possible choose User Authentication: Oracle Wallet(SSL) And Password in the popup list I use OID 10g, when I use OID 9.2
-
R12 TOI documents for AR, AP and GL
Hi, From where do I download R12 TOI documents for AR, AP and GL modules? Any pointers in this regard would be helpful. Thanks.