import var and function from ksh script to another ksh script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting import var and function from ksh script to another ksh script
# 1  
Old 04-02-2008
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:
Code:
var1= "aaa"
var2= "bbb"
var3= "ccc"
...
function ab { ...}
function bc { ... }
function cd { ...}
...

and import this from all my others scripts
? is there any way to do except using export command ?

[sourcing a sh script . myscript or ./myscript work but not in ksh]


thx

Last edited by wolfhurt; 04-02-2008 at 09:38 AM..
# 2  
Old 04-02-2008
Sourcing some code to establish variables and functions should work fine in ksh. I do it all the time.
. /path/to/included file
. is the name of the command. It must be followed by a space. Then comes the file to be sourced.
# 3  
Old 04-02-2008
. thescript dont work in ksh, my script is on the same directory

but . ./thescript work for sourcing in same directory

thank you
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 pass and read an array in ksh shell script function.?

I'm able to read & print an array in varaible called "filelist" I need to pass this array variable to a function called verify() and then read and loop through the passed array inside the function. Unfortunately it does not print the entire array from inside the funstion's loop. #/bin/ksh... (5 Replies)
Discussion started by: mohtashims
5 Replies

2. Shell Programming and Scripting

In ksh script what is this BEGIN and END in this function?

Can Someone please explain why BEGIN and END statement is used inside function? How does that help in scripting? function fileformatting { CleanupMask="xXxX" sed 's/^.//' < ${AllFile} > ${AllFile}.tmp echo $(wc -l ${AllFile}.tmp) `awk -v CleanupMask=${CleanupMask} ' BEGIN... (2 Replies)
Discussion started by: later_troy
2 Replies

3. Shell Programming and Scripting

ksh - building a var

This works #!/bin/ksh FILE="file.txt" dosumtin () { date >> FILE } for i in {1..5} do dosumtin done cat $FILE But instead of building a file, I want to do the same with a var or an array. That is, to build one that saves all 5 of the subs execution responses in a var or an... (8 Replies)
Discussion started by: popeye
8 Replies

4. Shell Programming and Scripting

Activate and deactivate function within a ksh script

Hi, I have written a function which will blink a text "Scanning...". Now in the main script when I am doing the scan in the server I want to call this function so that user will see a blinking text on the screen and at the same time script will proceed will the scan function. Once scan is... (2 Replies)
Discussion started by: suhasingale
2 Replies

5. Shell Programming and Scripting

ksh: what does var=$(command) mean?

hi, i can see in a script it contains var=$( myFile | grep -i err ) why has this person done it like this? why not just var=`myFile | grep -i err` thanks (9 Replies)
Discussion started by: JamesByars
9 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

Ksh script function, how to "EXIT 2" without killing the current process?

Hi, Using AIX 5.3 and Ksh. />ls -al /usr/bin/ksh -r-xr-xr-x 5 bin bin 237420 Apr 10 2007 /usr/bin/ksh /> I recently started working for a new employer. I have written UNIX K-Shell scripts for many years and have never had this particular issue before. Its perplexing me. I have... (2 Replies)
Discussion started by: troym72
2 Replies

8. Shell Programming and Scripting

Can you ref/link/import a function from external ksh script?

Hey guys, I'm not the best AIX scripter about but I can flounder my way thru them to create what I need. Anyhow, I have various scripts that perform various actions and processes. I was tasked to come up with a single form of logging that all the scripts could implement so that the output... (2 Replies)
Discussion started by: isawme
2 Replies

9. 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

10. Shell Programming and Scripting

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... (6 Replies)
Discussion started by: ammu
6 Replies
Login or Register to Ask a Question