how do i execute nohup and background job inside the korn script for db2


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how do i execute nohup and background job inside the korn script for db2
# 1  
Old 02-28-2012
how do i execute nohup and background job inside the korn script for db2

Code:
load_cursor_stmt()
{
ls /db/admin/ddl/rmn01000/load_cursor*.sql|while read file
 do
 echo "${file}"
   `nohup  db2  -tvf "$file"  \&`
done
}

Error:
-------


Code:
/admin/ddl/rmn01000/load_cursor5.sql /db/admin/ddl/rmn01000/load_cursor6.sql
+ read file
+ echo /db/admin/ddl/rmn01000/load_cursor1.sql
++ nohup db2 -tvf /db/admin/ddl/rmn01000/load_cursor1.sql '&'
+ DB21004E You cannot specify both an input file and a command when invoking the Command Line Processor.


Last edited by methyl; 02-28-2012 at 07:49 PM.. Reason: please use code tags
# 2  
Old 02-28-2012
Usually nohup is around the outer script, and then all the children are nohup. Some db2 tools talk to background processes, so it helps to start the session in the nohup script. Then you are just generating input. You can mix files and script decisions by just letting the script generate all the input to the db2 client.

Is this a product called "Korn script for DB2" or just a ksh script talking through a db2 command line client?

If it gets too painful, you can use xigole jisql and the free jdbc jars to get a nice friendly and simple db2 client.
# 3  
Old 02-28-2012
First impressions, too much punctuation. Assuming that this is meant to be a Korn Shell Function called with load_cursor_stmt later in the full script:

Corrected code:
Code:
load_cursor_stmt()
{
ls /db/admin/ddl/rmn01000/load_cursor*.sql|while read file
 do
 echo "${file}"
   nohup db2 -tvf "$file" &
done
}

The backticks are pointless and not required or desirable. The escape of the background command "&" as "\&" is not required or desirable and caused the parameter "&" to be presented to the "db2" command and not executed by the Shell.

Last edited by methyl; 02-28-2012 at 08:08 PM.. Reason: removed excess space characters, removed some comment. Corrected spellin of corrected!
# 4  
Old 02-28-2012
It is not working ,Pls see the error


DB21018E A system error occurred. The command line processor could not
continue processing.
DB21018E A system error occurred. The command line processor could not
continue processing.
DB21018E A system error occurred. The command line processor could not
continue processing.
DB21018E A system error occurred. The command line processor could not
continue processing.
DB21018E A system error occurred. The command line processor could not
continue processing.
DB21018E A system error occurred. The command line processor could not
continue processing.



load_cursor_stmt()
{
ls /db/admin/ddl/rmn01000/load_cursor*.sql|while read file
do
nohup db2 -tvf "$file" &
done

}
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Korn Shell script in stopped state while running in background

Hi, I want to run a shell script in background . but its going to stopped state $ ksh cat_Duplicate_Records_Removal.ksh & 8975 $ + Stopped (tty output) ksh cat_Duplicate_Records_Removal.ksh & why is this happening? Also could anyone please tell me what is a stopped... (12 Replies)
Discussion started by: TomG
12 Replies

2. Shell Programming and Scripting

Nohup inside shell script

Hi, I want to run another script inside shelll script in nohup mode. let explain. under the same folder ,I have two scripts scrone.sh scrtwo.sh In scrone.sh if then nohup ./scrtwo.sh & echo " Script two has been run correctly" else echo " Exiting from the script" fi If... (3 Replies)
Discussion started by: ckchelladurai
3 Replies

3. Shell Programming and Scripting

How to execute korn shell script from different directory

Guy's , I need to run korn shell script from different directory, usually I run the script using ./details.ksh in the same directory but now I need to run the file and process details using awk code. Now I am running the script this way but with no luck Directory = home/users/work ... (3 Replies)
Discussion started by: James_Owen
3 Replies

4. Shell Programming and Scripting

Need help in listing directories inside korn shell script

Hi All, I need to loop through each item in current path, if it is a direcotry do soemthing, if its a file jsut skip it and move to next item in loop. Tried if test ! -d $i then echo "The current item $i is not a directory" continue fi This doesnt seems to be working .... (8 Replies)
Discussion started by: justchill
8 Replies

5. Shell Programming and Scripting

How to pass tablenames from a file to shell script to execute create statement in DB2

Hi, I am new to Shell Scripting, and I need to create nicknames for 600 tables in db2. I have the file names in a text file and i have to pass these table names to a shell script create nicknames in db2. Can some one please help me in this regard. (1 Reply)
Discussion started by: kamalanaatha
1 Replies

6. Shell Programming and Scripting

Using ssh to execute a remote script in the background

Help please!! I want to use ssh to execute a remote exe and while it's running I want to query for the process ID of the exe (2 different ssh commands) 1. sshpass -p "<passwd>" ssh -f -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@<ipaddress> nohup /tmp/mmds_asyn & 2.... (0 Replies)
Discussion started by: rvompoluTMW
0 Replies

7. UNIX for Dummies Questions & Answers

nohup - sub job in script not executing until I exit

My job is launched using this command: I'm at home and having VPN drops so I used nohup and background. nohup perf_mon -c rating_4_multi,cfg & The main script is PID 26119, and the sub task under it is 26118 which is not running - just sits there. 26119 runs forever but nothing else runs. I... (2 Replies)
Discussion started by: ido1957
2 Replies

8. Shell Programming and Scripting

Unix Korn Shell script on Solaris to DB2 UDB LUW database

I am rather new to korn shell scripting and attempting to write a Unix script that would detach, attach a range partition table in DB2 UDB LUW database. This would be a job scheduled in control M that reads in an input file with 5 parameters passed to it from the application. I don't have much... (1 Reply)
Discussion started by: tjhanso
1 Replies

9. Shell Programming and Scripting

Execute Script using nohup and &

Hi all, I have one script test.sh for which I pass two arguments. In the same script I need to submit this script in background using nohup. My script like this and it is working in HP-UX os but not Solaris. #! /bin/sh if then MTR_PID=$$ export MTR_PID echo "test.sh $1 $2... (3 Replies)
Discussion started by: sridhar_423
3 Replies

10. Shell Programming and Scripting

unable to execute background job

I am unable to execute the below command in background. Plz suggest. #> ./test input >out & 913618 + Stopped (SIGTTIN) ./test input >out & Suresh (1 Reply)
Discussion started by: suresh3566
1 Replies
Login or Register to Ask a Question