Migrating Shell scripts from HP-Unix 11i to OEL 5.0
Hi :
We recently migrated the databases from a HP-Unix server 11i to OEL 5.0 Server. As a part of the move we also had to migrate the shell scripts from Unix.
The source scripts uses B-Shell and when we try to run this on OEL nothing works. It looks like we may have to rewrite for BASH or KORN Shell in OEL 5.0.
I have very limited experience in writing shell scripts and need expert guidence on how the existing script could be modified to work in Linux. Any useful pointer would be great help.
Regards,
Bala
BMP wrote:
Hi :
We recently migrated the databases from a HP-Unix server 11i to OEL 5.0 Server. As a part of the move we also had to migrate the shell scripts from Unix.
The source scripts uses B-Shell and when we try to run this on OEL nothing works. It looks like we may have to rewrite for BASH or KORN Shell in OEL 5.0.
I have very limited experience in writing shell scripts and need expert guidence on how the existing script could be modified to work in Linux. Any useful pointer would be great help.
Regards,
BalaI assume you mean 'Bourne shell' ... though possibly you have Posix (which is meant to be close to ksh).
In general ... with exceptions ... ksh and bash are a superset of (bourne shell).
Two things can help:
[1] Check the first line in the scripts and indicate what it is .....
head -1 some-shell-script.
Does hte she-bang command exit on OEL?
[2] Post one or show of the error messages here.
... It is possilbe you are getting one basic error/problem repeated everywhere rather than a lot of different eror messages
If you give examples ... without compromising your security .. that may be a more focused answer
Similar Messages
-
Error while executing unix shell script from java program
Hi All,
I am trying to execute unix shell script from a java program using Runtime.execute() method by passing script name and additional arguments.
Code snippet :
Java Class :
try{
String fileName ="test.ksh";
String argValue ="satish"; // value passed to the script
String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
Process proc = Runtime.getRuntime().exec(exeParam);
int exitValue = proc.waitFor();
sop("Exit Value is : "+exitValue);
catch(Exception e)
e.printStackTrace();
}Test.ksh
export -- application realated paths..
nohup abc.exe 1> test.log 2>&1;
$1
exit.By running the above java class , i am getting exit Value: 139 and log file test.log of 0 bytes.
when i am running the same command (/usr/bin/ksh test.ksh satish) manually, it's calling abc.exe file successfully
and able generate the logs properly.
Pls let us know where exactly i am stuck..
Thanks in advance,
Regards,
SatishHi Sabre,
As per the guidelines provided by the article, i had done below changes..
InputStream is = null;
InputStreamReader iStreamReader = null;
BufferedReader bReader = null;
String line = null;
try{
String fileName ="test.ksh";
String argValue ="satish"; // value passed to the script
String exeParam = "/usr/bin/ksh "+fileName+" "+argValue;
Process proc = Runtime.getRuntime().exec(exeParam);
is = proc.getErrorStream();
iStreamReader = new InputStreamReader(is);
bReader = new BufferedReader(iStreamReader);
System.out.println("<ERROR>");
while((line = bReader.readLine()) != null)
System.out.println("Error is : "+line);
System.out.println("</ERROR>");
int exitValue = proc.waitFor();
sop("Exit Value is : "+exitValue);
catch(Exception e)
e.printStackTrace();
Now , it's showing something like..
<ERROR>
</ERROR> -
How to execute unix shell script from Java ...
Hi,
Anyone know how to execute unix shell script from Java?
Suppose I have several shell scripts written in perl or tcl or bash.
I just want to catch the output of that script.
Is there any ready to use module/object for this?
Please let me know, this is quite urgent for my study assigment.
Thanks in advance,
Regards,
meLook up Runtime.exec()
-
How to pass arguments to a Unix shell script from PL/SQL?
We want to run a Linux shell script from PL/SQL (10g). This is our code to run the script only and it works fine.
dbms_scheduler.create_job
job_name=>'RUN_LINUX_SCRIPT_' || v_job_name,
job_type=>'EXECUTABLE',
job_action=>'/vol0/FileLoadDir/Bank/DATA_FILES/spell_check.sh',
enabled=>TRUE,
auto_drop=>FALSE
);Now we have a requirement to pass 2 arguments to the .sh file. In the .sh file the 2 arguments are defined as $1 and $2.
I used this method.
dbms_scheduler.create_job
job_name=>'RUN_LINUX_SCRIPT_' || v_job_name,
job_type=>'EXECUTABLE',
job_action=>'/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2.sh',
--job_action=>'/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2.sh /vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt /vol0/FileLoadDir/Bank/DATA_FILES/abcdefghij.txt',
--job_action=>'#!/bin/bash spell /vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt > /vol0/FileLoadDir/Bank/DATA_FILES/abcde.txt',
number_of_arguments => 2,
enabled=>FALSE,
auto_drop=>FALSE,
comments => 'Testing by Channa'
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
job_name => 'RUN_LINUX_SCRIPT_' || v_job_name,
argument_position => 1,
argument_value => '/vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt');
DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
job_name => 'RUN_LINUX_SCRIPT_' || v_job_name,
argument_position => 2,
argument_value => '/vol0/FileLoadDir/Bank/DATA_FILES/abcdefghij.txt');
DBMS_SCHEDULER.enable (name => 'RUN_LINUX_SCRIPT_' || v_job_name);But I get an error saying:
STANDARD_ERROR="/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2.sh: line 4: read: `/vol0/FileLoadDir/Bank/DATA_FILES/ebill2.fmt_form_strings_.txt': not a valid identifier
/vol0/FileLoadDir/Bank/DATA_FILES/spell_check2"Check this post:
pass parameter from PL/SQL to Unix "as is" -
How to run unix shell script from java web applet
hi all
i have created one java applet. my apache web server is on unix server.
i have created one shell script in same directory where my .class and .htm files reside...
how to run this shell script from applet? it should search this .sh file on server and not on the client browser machine...
thanks in advanceI suppose you could make the shell script into a CGI, configure the server to execute CGIs, and then make the applet open the URL of that CGI.
-
Calling Unix shell script from PL/sql code
Hi
I need to call a shell script from a procdeure which i need to run in toad. Let me kno whow can i do that and connect to unix box with an example.Thanks Avinash,
That on was very useful.
When I try to execute I got the following error.
Could you let me now What privileges are required?
SQL> BEGIN
dbms_scheduler.create_job(job_name => 'myjob',
job_type => 'executable',
job_action => '/home/rananto/a.sh',
enabled => TRUE,
auto_drop => TRUE);
END;
/ 2 3 4 5 6 7 8
BEGIN
ERROR at line 1:
ORA-27486: insufficient privileges
ORA-06512: at "SYS.DBMS_ISCHED", line 99
ORA-06512: at "SYS.DBMS_SCHEDULER", line 262
ORA-06512: at line 2
SQL> exec dbms_scheduler.run_job('myjob');
BEGIN dbms_scheduler.run_job('myjob'); END;
ERROR at line 1:
ORA-27475: "CRDM.MYJOB" must be a job
ORA-06512: at "SYS.DBMS_ISCHED", line 150
ORA-06512: at "SYS.DBMS_SCHEDULER", line 441
ORA-06512: at line 1 -
Run Unix command / Run Unix shell script from Forms9i
Hi,
I have a requirement to run Unix command and Unix shell scripts from Forms9i.
I know HOST command cannot be used directly. I also know we can create some JAVA stored procedure to perform the task, but I don't want to create any JAVA stored procedure as there are some security concerns.
Please point me towards any other way to achieve the same.
I would really appreciate your help.
Thanks,
KumarThere is no reason why HOST can't be used. This is what it is for. As for using Java, it is not a stored procedure that you would be using, it would be imported Java (imported into the form).
The best way to use the HOST command is to call a script (.sh) rather than calling a Unix command directly. This is because HOST will not pick up environment variables set at the system level. So the script would first need to set the necessary environment variables then call the desired commands. -
Need Example on calling a unix shell script from oracle stored procedure
Hi
Can anybody give example on how to call unix shell script from an Oracle stored procedure. Please give a small example on how to do this .I need this urgently please.
Have a nice time.
Thanks & Regards
JogeshIf you are on 10g you can also use DBMS_SCHEDULER. See Re: Excute Unix command Using PL SQL
-
Calling UNIX shell script from ODI package?
Hi,
How Can we call UNIX shell script from ODI package?
I have a ftp_ss.sh script which which ftps a file from remote server to local server, archives the last file and renames new file to the standard (ie file data store)name.
I want to run the above script and interfaces from a package.
Any help is greately appreciated.
Thanks,
RDIn the package window, put "OS Command" from the toolbox.
Provide the command parameters to this tool in form of "/path/to/script/ftp_ss.sh" -
Invoking unix shell scripts from java?
Hi,
could someone explain to me how one wuld invoke unix shell scripts from java.
Also, could you invoke Visual Basic scripts from java.
Finally, could you do this from an EJB?
thanks for any help....
suduI just posted a snippet of this solution in the topic about widows commands chech it out it works just fine for unix shell scripts.
--Ian -
Can I call host file ( Unix Shell script ) from Oracle 10g trigger
Hi,
I am new to Oracle 10g. Can I call host file ( unix shell script ) from Oracle 10g trigger ?. I know it is possible. Pl explain me with small example
thanks & regards
paraguser12009546 wrote:
Hi,
I am new to Oracle 10g. Can I call host file ( unix shell script ) from Oracle 10g trigger ?. I know it is possible. Pl explain me with small example
thanks & regards
paragIf you are in 10g, you can simple call shell script from DBMS_SCHEDULER:
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'TEST_SCRIPT',
job_type => 'EXECUTABLE',
job_action => 'PATH_OF_YOUR_SCRIPT',
start_date => SYSDATE,
repeat_interval => 'FREQ=MINUTELY; INTERVAL=1',
enabled => TRUE,
comments => 'Shell script from Oracle'
END;
/ -
Execute a unix shell script from forms9i
Hi ,
I would like to execute a unix shell script form a form when they pressed a button. The forms server is on Linux machine. I tried but when I pressed the button nothings happen. Could some one please help me how I could get working.
Is there is a way I could execute the unix shell script from PL/SQL proceudre or package.
Please some one help me.
BainYou would not expect to see anything happening because the
script cannot directly send output to the web form. However, you can get it to write output to a file and use web.show_document in the form after the host command to display the file and see the output. -
Call a UNIX shell script from an oracle stored procedure
We need to call a UNIX shell script from an oracle stored procedure
i.e. the control should come back to the procedure once the script completes. Can any body help to achieve this ?There are various ways in achieving this.
For Example, you can call a PRO*C-Library residing on the database server.
This requires a PL/SQL library to be generated and some changes to the Listener configuration.
It is also possible to implement a java procedure on the database being invoked by a PL/SQL wrapper class.
In this way (and if used right) there is also granularity regarding the filestructure permissions given and it may be called during a Forms or other PL/SQL session.
The article below explains a more generic approach how to invoke shell commands from within an Oracle Instance.
Be careful with this, because it really works ;)
Refer to :
http://www.oracle-base.com/articles/8i/ShellCommandsFromPLSQL.php
Message was edited by:
user434854 -
Can i call unix shell script from B2B callout.
Hi,
We had a requirement to invoke a unix shell script from B2B callout implemented class. Here is the code in implementation class:
public void execute(CalloutContext context,List input,List output)
throws CalloutDomainException, CalloutSystemException {
try {
CalloutMessage cmIn = (CalloutMessage)input.get(0);
FileOutputStream fos = null;
String inputFile = "/home/orasoad/digitalsign/input/test.txt";
String outputFile = "/home/orasoad/digitalsign/output/test.txt.gpg";
File outFile = new File(inputFile);
String str =cmIn.getBodyAsString();
fos = new FileOutputStream(outFile);
Writer out = new OutputStreamWriter(fos);
out.write(str);
out.close();
String shellFile = "/home/orasoad/digitalsign/dg.sh";
String cmd[] = new String[] { shellFile, inputFile, outputFile };
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(cmd);
int i = pr.waitFor();
BufferedReader br = new BufferedReader(new InputStreamReader(pr.getInputStream()));
StringBuffer sb = new StringBuffer();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
CalloutMessage cmOut = new CalloutMessage(sb.toString());
output.add(cmOut);
} catch (Exception e) {
throw new CalloutDomainException(e);
We were able to execute the unix shell script from standalone java class with same code. But some how it is not working as expected while invoking the B2B java callout.
Is it possible to invoke unix shell script from B2B callout?
Please give inputs.
Regards,Though it's not a good idea to invoke shell scripts from java callout but technically it will work.
But some how it is not working as expected while invoking the B2B java callout.What is not working as expected? Any error in the log (server-diagnostic.log or server.out)?
Regards,
Anuj -
How I run a shell script from the scheduler on 10.2.0.2.0 ?
Hello Oracle People,
I'd like to run a shell script from the Scheduler in my 10g database.
Right now it is a simple shell script.
Eventually it will wrap RMAN commands to back up my DB.
I wrote a simple pl/sql script to create a job:
-- cr_job10.sql
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'my_backup_job',
job_type => 'EXECUTABLE',
job_action => '/h/oracle/scripts/tst.sh',
start_date => '06-SEP-07 5.33.00PM US/Pacific',
repeat_interval => 'FREQ=DAILY',
end_date => '08-SEP-07 4.00.00PM US/Pacific',
enabled => TRUE,
comments => 'My Backup Job');
END;
I see no errors when I run the above procedure.
I checked DBA_SCHEDULER_JOBS and the job is in there.
The scheduler, though, errors out with an error which I see in a trace file:
/h/oracle/admin/orcl/bdump/orcl_j000_22396.trc
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production
With the Partitioning, OLAP and Data Mining options
ORACLE_HOME = /h/oracle/product/10r2
System name: SunOS
Node name: sol
Release: 5.10
Version: Generic_118855-14
Machine: i86pc
Instance name: orcl
Redo thread mounted by this instance: 1
Oracle process number: 15
Unix process pid: 22396, image: oracle@sol (J000)
*** ACTION NAME:(MY_BACKUP_JOB) 2007-09-06 17:33:00.175
*** MODULE NAME:(DBMS_SCHEDULER) 2007-09-06 17:33:00.175
*** SERVICE NAME:(SYS$USERS) 2007-09-06 17:33:00.175
*** CLIENT ID:() 2007-09-06 17:33:00.175
*** SESSION ID:(140.13520) 2007-09-06 17:33:00.175
*** 2007-09-06 17:33:00.175
ORA-12012: error on auto execute of job 53267
ORA-27369: job of type EXECUTABLE failed with exit code: 274662
I googled on this:
ORA-27369: job of type EXECUTABLE failed with exit code: 274662
Google returned only 1 hit.
There, I see some evidence that I need to configure something inside
of Oracle to run shell scripts from the scheduler, but possibly just
for machines running windows. I'm running Solaris.
Do any of you know what I need to configure inside of Oracle to
run shell scripts from the scheduler?
-OwenHello people,
I should have added this bit of information:
"The script runs fine from oracle's crontab."
"The script runs fine from a shell owned by oracle."
I'm getting responses telling me to check my env variables and permissions
which would be helpful to a UNIX novice.
I have a feeling that no one is using the scheduler to run RMAN scripts.
Tim Hall suggested I take a close look at these files:
$ORACLE_HOME/rdbms/admin/externaljob.ora
$ORACLE_HOME/bin/extJob
Currently I'm setup like this:
bash sol root /h/oracle/product/10r2/bin 31 #
bash sol root /h/oracle/product/10r2/bin 31 # ll $ORACLE_HOME/rdbms/admin/externaljob.ora
-rw-r--r-- 1 root dba 52 Sep 7 15:29 /h/oracle/product/10r2/rdbms/admin/externaljob.ora
bash sol root /h/oracle/product/10r2/bin 32 #
bash sol root /h/oracle/product/10r2/bin 32 # cat $ORACLE_HOME/rdbms/admin/externaljob.ora
# externaljob.ora
run_user = rman
run_group = rman
bash sol root /h/oracle/product/10r2/bin 33 #
bash sol root /h/oracle/product/10r2/bin 33 #
bash sol root /h/oracle/product/10r2/bin 33 #
bash sol root /h/oracle/product/10r2/bin 33 # ll $ORACLE_HOME/bin/ext*
-rwsr-x--- 1 rman dba 30388 Sep 21 2006 /h/oracle/product/10r2/bin/extjob*
-rwsr-x--- 1 rman dba 30392 Sep 21 2006 /h/oracle/product/10r2/bin/extjobo*
-rwsr-x--- 1 rman dba 34468 Sep 21 2006 /h/oracle/product/10r2/bin/extproc*
-rwxr-xr-x 1 oracle dba 300 Sep 21 2006 /h/oracle/product/10r2/bin/extusrupgrade*
bash sol root /h/oracle/product/10r2/bin 34 #
bash sol root /h/oracle/product/10r2/bin 34 #
bash sol root /h/oracle/product/10r2/bin 34 #
On my system, the user 'nobody' has no shell so I cannot use nobody.
I created a user named rman:
bash sol root /h/oracle/product/10r2/bin 34 #
bash sol root /h/oracle/product/10r2/bin 34 #
bash sol root /h/oracle/product/10r2/bin 34 # su - rman
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
$
$ id
uid=220(rman) gid=220(rman)
$
$
$ date
Fri Sep 7 16:30:03 PDT 2007
$
$
Jared points out that rman needs access to extproc:
$ ls -la /h/oracle/product/10r2/bin/extproc
-rwsr-x--- 1 rman dba 34468 Sep 21 2006 /h/oracle/product/10r2/bin/extproc
$
$
Here is a demo of rman running his script:
bash sol root /h/oracle/product/10r2/bin 35 # su - rman
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
$
$
$ ls
scripts
$
$
$ scripts/tst.sh
$
$
$ cat scripts/tst.sh
#! /bin/sh
/usr/bin/date > /tmp/tst.sh.out.txt 2>&1 &
exit 0
$
$
$ cat /tmp/tst.sh.out.txt
Fri Sep 7 16:31:23 PDT 2007
$
$ rm /tmp/tst.sh.out.txt
$
I am focused on this error:
ORA-27369: job of type EXECUTABLE failed with exit code: 274662
And I am focused on this exit code: 274662
What does 274662 mean?
If the Scheduler gives me an error like "274662" rather than some English,
it's obvious to me the Scheduler is a POS and I should not use it.
And of course,
If I cannot run RMAN from Oracle Scheduler, I'll use cron.
-Owen
Maybe you are looking for
-
Simple but reliable small office setup
Hi group, I need some advice on setting up a simple but reliable small office wireless network. Up until now, we had a consumer AP combined with wired connections. However, we're moving to a new office where it's difficult to implement a wired networ
-
How to implement Approval hierarchy for Sales Order in Order Management.
Hi, We need approval process for sale orders in Order Management module. Currently we are using credit HOLD option for orders at shipping level. The issue we are facing now is we can not cancel those orders who contains Service Line item in it while
-
Hi gurus, i have imported an XSD file as an external definition and use this for a mapping. After my mapping i have an xml file like: <?xml version="1.0" encoding="UTF-8" ?> - <ns1:Aviso xmlns:ns1="http://Post.AG/PartnerInterface/Schemas/PVSdeAt/Av
-
Illustrator CS4 - Saving Buttons Created in Illustrator CS4
How do I save a created button in Illustrator cs4 without the whole page - just the button - it was straightforward in illustrator CS3.
-
OBIEE Evaluate - "Essbase error : Repeated dimension in MDX query"
Hi, I'm using OBIEE 11.1.1.6.2 BP1 on top of Essbase. I have a project dimension in Essbase with three levels - Total Project -> Project Class -> Project. I have created a new logical column in OBIEE to query two levels from project dimension, using