executing a ksh script from another ksh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting executing a ksh script from another ksh script
# 1  
Old 07-26-2006
executing a ksh script from another ksh script

Hi,

I'm new to unix scripting.How can i call a script from another script.
I have a.ksh and b.ksh .I have to call b.ksh from a.ksh after it is successfully exceuted.

I tried using
#!/bin/ksh -x in a.ksh and at the end i have used /path/b.ksh

My problem is it is executing only a.ksh.it is not going to b.ksh

Can anyone suggest some solution for this
Thanks !
# 2  
Old 07-26-2006
Simply mention the path of b.ksh in a.ksh, suppose if both are in same directory, you could simply add in a.ksh:
Code:
./b.ksh

If no joy, then check if b.ksh is executable?
# 3  
Old 07-26-2006
Hi shereen,

I have tried using that but it is not working because
I have to pass a run time variable for b.ksh.i'm passing same variable for a.ksh also.How can i pass the same variable for b.ksh
# 4  
Old 07-26-2006
Suppose you want to do like this:
Code:
#! /bin/ksh
echo "Pass test var to b.ksh"
test=13
export test
./b.ksh

otherwise post code of a.ksh and b.ksh here and mention what exactly you want.

Regards,
Tayyab
# 5  
Old 07-26-2006
Hi

the code is too lengthy.
In short a.ksh is for running a datastage job.
so for executing the job the command i'll give is
./a.ksh dev(environment) jobname.
So now in a.ksh only i'm trying to call b.ksh .this is to ftp the file.for running this script the command should be ./b.ksh dev(environment).

So now i need to pass the dev to b.ksh

So how can i do this
# 6  
Old 07-26-2006
I'm not sure what you are exactly looking for, maybe any one else could help you on this issue.

Regards,
Tayyab
# 7  
Old 07-26-2006
Quote:
Originally Posted by ammu
Hi

the code is too lengthy.
In short a.ksh is for running a datastage job.
so for executing the job the command i'll give is
./a.ksh dev(environment) jobname.
So now in a.ksh only i'm trying to call b.ksh .this is to ftp the file.for running this script the command should be ./b.ksh dev(environment).

So now i need to pass the dev to b.ksh

So how can i do this
Code:
#! / bin/ksh
# a.ksh
# your code.

# save argument 1 to be used later.
DEV_ENV=$1 

# rest of the code.

# invoke b.ksh
./b.ksh $DEV_ENV

Infact I dont think you need to save $1. You might as well invoke b.ksh as
Code:
./b.ksh $1

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to fix this "Input is not UTF-8" while executing ksh script?

Hi, I have an automated script which have set of sqls but when i am trying to execute the automated script by using nohup command, it is throwing an error like "Input is not UTF-8" . And when i digged in to it, i am getting some "Â" character in the shell script. How to avoid this!? Thanks. (1 Reply)
Discussion started by: Samah
1 Replies

2. UNIX for Dummies Questions & Answers

Executing ksh script to remote server want output on same window

I'm having a brain freeze moment. I've created a ksh script in AIX that ssh's to a remote server, executes some commands, and then logs out. All of this is sent to a file. I then have the script cat the file so i can see the output. Even though the cat command is outside of the remote session part;... (5 Replies)
Discussion started by: seekryts15
5 Replies

3. Shell Programming and Scripting

Two for loops in ksh script only one not executing

Hello, I have two "for loops" in my script and the second one is not executing the way i want. Script: #!/bin/ksh IFS=' ' printf "Enter Account name: " read A B C D E F G H I J K L M N O for i in ${A} ${B} ${C} ${D} ${E} ${F} ${G} ${H} ${I} ${J} ${K} ${L} ${M} ${N} ${O};... (3 Replies)
Discussion started by: seekryts15
3 Replies

4. Shell Programming and Scripting

executing ksh script

I am trying to call a ksh script from another ksh script. in the called script , i am doing sum calculation(used typeset etc) suppose a.ksh is the calling script and b.ksh is the called script . . b.ksh (used this inside a.ksh) this execution gives some error like bad number. but when i... (1 Reply)
Discussion started by: urfrnddpk
1 Replies

5. UNIX for Dummies Questions & Answers

problem in Executing script in ksh

Hi, I am in ksh. below mentioned 3 commands I executed at command prompt & got the expected results. csh source csh_infa <special command> Now I have to do this in the script in ksh. I entered it as it is. #!/bin/ksh csh source csh_infa <special command> Now after... (1 Reply)
Discussion started by: girish_kanak
1 Replies

6. Shell Programming and Scripting

KSH script to run other ksh scripts and output it to a file and/or email

Hi I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email. For example ------- Script ABC ------- a.ksh b.ksh c.ksh I need to call all three scripts execute them and... (2 Replies)
Discussion started by: pacifican
2 Replies

7. Shell Programming and Scripting

import var and function from ksh script to another ksh script

Ih all, i have multiples ksh scripts for crontab's unix jobs they all have same variables declarations and some similar functions i would have a only single script file to declare my variables, like: var1= "aaa" var2= "bbb" var3= "ccc" ... function ab { ...} function bc { ... }... (2 Replies)
Discussion started by: wolfhurt
2 Replies

8. Shell Programming and Scripting

tracing a ksh script within a ksh script

I normally trace a script with the ksh -x <script name> and redirect strderr to file. But if you have a script like the examble below...... vi hairy bear=`grep bear animals` if then ksh more_animals fi If I ksh -x hairy it won't trace "more_animals" unless I put a -x in it. Is... (1 Reply)
Discussion started by: shorty
1 Replies

9. Shell Programming and Scripting

Full path of executing script in ksh?

Hello all, Here's the scenario: I've got a script, let's call it script1. This script invokes another script, which we'll call set_env, via the dot "." command, like so: File: #!/bin/ksh # region_id=DEV . set_env ${region_id} and so on. Script set_env sets up an... (2 Replies)
Discussion started by: BriceBu
2 Replies

10. Shell Programming and Scripting

Executing ksh script from cgi

Hi all, I'm developing a system which requires me to run a ksh script from within a cgi script. What sort of syntax will I need to do this, I'm sure it's simple but can't find out how anywhere! Thanks. (1 Reply)
Discussion started by: hodges
1 Replies
Login or Register to Ask a Question