This is about running SQL*Plus in a batch mode. Suppose you have a script (shell or batch file) that calls SQL*Plus to run a SQL in a batch mode. I am talking about running it from Command line, thus:
$ sqlplus <user_id/password>@SID @<sql_file_name)
Chances, you will want to exit SQL*Plus as soon as the script is done (EOF file is reached in SQL file), so we can continue our processing.
Typically, we add an EXIT statement at the end of the SQL file itself and this will force SQL*Plus to quit. What if you forgot or couldn't add EXIT (you use the same script in different scenarios). If you don't have an EXIT or QUIT statement at the end of your SQL file, you will end up seeing the SQL Prompt:
SQL>
Here is a quick tip to exit Sql*Plus after it's done with the script:
exit | sqlplus <user_id/password>@SID @<sql_file_name)
(That's it. Essentially piping exit into sqlplus command! When the End of file is reached, SQL*Plus returns to the shell and your shell script can go on!
This tip works on both DOS (Windows command prompt)_ and *nix systems.
Showing posts with label DOS. Show all posts
Showing posts with label DOS. Show all posts
Friday, December 7, 2012
Monday, June 20, 2011
Pinging windows PC behind firewall
If your windows PC (XP, Vista) has firewall turned on, it may not respond to ping from other computers on the network. To allow pinging on this computer, try the following command:
To disable the same,
Make sure you open command prompt as an Administrator.
Netsh is the command line utility available in windows command prompt (DOS box) to help with network configuration. See here for more on netsh.
The above settings can also be set in windows firewall settings GUI (screen) in control panel. Surprisingly it's a little more convoluted. See here
netsh firewall set icmpsetting 8To disable the same,
netsh firewall set icmpsetting 8 disableMake sure you open command prompt as an Administrator.
Netsh is the command line utility available in windows command prompt (DOS box) to help with network configuration. See here for more on netsh.
The above settings can also be set in windows firewall settings GUI (screen) in control panel. Surprisingly it's a little more convoluted. See here
Labels:
DOS
,
DOS/Windows
,
Misc
,
Networking
,
PC
Monday, November 22, 2010
Script: PB backup – Using PB ORCA to export PBLs
A basic Operating system level unit in Powerbuilder is a library file (.PBL). Each PBL file is a self contained directory in itself, with the objects stored inside in a proprietary binary format. You need Powerbuilder to view and work with this directory structure (System tree, Library painter etc).
Sometimes, it would be nice to be able to work with individual objects as text files at the OS level. This will enable us to use any text utilities to work with the objects as files (like you would a Java or C++ file). For e.g., I have a Perl script to grep through the exported text files. With text files, you can store away these source files in any version control systems (PVCS, SVN etc) easily. And you can easily diff 2 versions of an object by using any text diff tool (Of course, there are tools available to do these from inside PB, but it's just lot easier to work text files). PB allows the source code to be exported to text files with extensions, *.sr? (.srw for windows, .srd for datawindows etc.).
PB ORCA is an API that Powersoft developed early on for 3rd Party CASE tool vendors to work with PB objects. With PB ORCA, you can write programs to work PB libraries and objects from OS command line. Several object level operations available in PB IDE are also available in this API. Incidentally, there is a command line utility available with the same name (pborca.exe) on Google Code. The tool has several commands that correspond to API functions. You can create a ORCA script file (with .orc extension) and run it in batch mode using the tool. See here for a complete list of commands supported by the tool.
Below script uses pborca.exe in a DOS batch file to export all the objects in all the PBLs in a project directory to a corresponding directory structure. The batch file first loops on a list of .pbl files in a directory (passed in), and creates an ORCA script (latax.orc) with export commands. Then it runs the generated ORCA script using pborca.exe to export the object files (.*sr?). When the script finishes, you will have directory with several sub-directories, one for each PBL file exported.
This script uses several advanced features (%~ modifiers, ENABLEDELAYEDEXPANSION) of DOS Batch file. DOS scripts do several things a Unix script does, but it’s almost like an after thought! More on these later.
I use this script for daily backup of my development environment. Often times only a handful of files change on the developer's PC. Once I export the PBLs to a directory, I can diff 2 different versions using a diff tool. (I use Winmerge). The files can be optionally zipped up as well.
Pborca.exe can also handle the reverse (known as bootstrapping). Exported PB object files are only useful for performing file level operations. To be useful in a PB application, they will have to be imported back in to a PBL file again which can then be opened inside Powerbuilder. As of version 9, PB ORCA can be used to bootstrap as well. See here for the idea.
Sometimes, it would be nice to be able to work with individual objects as text files at the OS level. This will enable us to use any text utilities to work with the objects as files (like you would a Java or C++ file). For e.g., I have a Perl script to grep through the exported text files. With text files, you can store away these source files in any version control systems (PVCS, SVN etc) easily. And you can easily diff 2 versions of an object by using any text diff tool (Of course, there are tools available to do these from inside PB, but it's just lot easier to work text files). PB allows the source code to be exported to text files with extensions, *.sr? (.srw for windows, .srd for datawindows etc.).
PB ORCA is an API that Powersoft developed early on for 3rd Party CASE tool vendors to work with PB objects. With PB ORCA, you can write programs to work PB libraries and objects from OS command line. Several object level operations available in PB IDE are also available in this API. Incidentally, there is a command line utility available with the same name (pborca.exe) on Google Code. The tool has several commands that correspond to API functions. You can create a ORCA script file (with .orc extension) and run it in batch mode using the tool. See here for a complete list of commands supported by the tool.
Below script uses pborca.exe in a DOS batch file to export all the objects in all the PBLs in a project directory to a corresponding directory structure. The batch file first loops on a list of .pbl files in a directory (passed in), and creates an ORCA script (latax.orc) with export commands. Then it runs the generated ORCA script using pborca.exe to export the object files (.*sr?). When the script finishes, you will have directory with several sub-directories, one for each PBL file exported.
This script uses several advanced features (%~ modifiers, ENABLEDELAYEDEXPANSION) of DOS Batch file. DOS scripts do several things a Unix script does, but it’s almost like an after thought! More on these later.
I use this script for daily backup of my development environment. Often times only a handful of files change on the developer's PC. Once I export the PBLs to a directory, I can diff 2 different versions using a diff tool. (I use Winmerge). The files can be optionally zipped up as well.
Pborca.exe can also handle the reverse (known as bootstrapping). Exported PB object files are only useful for performing file level operations. To be useful in a PB application, they will have to be imported back in to a PBL file again which can then be opened inside Powerbuilder. As of version 9, PB ORCA can be used to bootstrap as well. See here for the idea.
REM 12,2009 Sam V
REM script to export PBLS using pborca.exe (ORCA interface to PB)
REM this copies all the folders from source (typically Z:) to target.
REM then it creates an ORCA script to export each pbl to the subdirectories.
REM Finally it runs the generated orca script in pborca
REM @echo off
echo %0 %1, %2
@REM copy all the directories from the powerbuilder root to the export directory
@REM if a x.PBL is already in x subdirectory, you may not need MKD1 below.
@echo creating the target directory; just copy the entire path with empty sub-directories
xcopy /t /e /I %1 %2
@REM Here we start generating the orca file to be used with <a href="http://pborca.googlecode.com/svn/trunk/install/deploy/pborca.htm">PBORCA</a>.
@echo session begin pborc100.dll > latax.orc
@echo off
@SETLOCAL ENABLEDELAYEDEXPANSION
@FOR /f "usebackq delims=" %%a IN (`dir /s /b %1*.pbl`) DO (
@set a1=%%~dpa
@REM echo a1=%a1%
@call set "a1=!a1:%~1=%~2!"
@REM MKD1
@REM This creates a sub-directory with the same name as PBL file
mkdir "!a1!"
@echo export %%~fa,,,!a1! >> latax.orc)
@echo session end >> latax.orc
@ENDLOCAL
@echo on
@echo run the script in pborca
pborca latax.orc
REM end of script
Labels:
Batch File
,
DOS
,
ORCA
,
Powerbuilder
,
Scripts
Subscribe to:
Posts
(
Atom
)