Sponsored Content
Top Forums Shell Programming and Scripting Can you ref/link/import a function from external ksh script? Post 302283403 by isawme on Tuesday 3rd of February 2009 09:26:55 AM
Old 02-03-2009
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 would be uniform and easy for our monitoring system to parse and use and ends up like this:

Code:
[DEBUG  ] 2009-02-03 14:16:30.000 [user001] [logging.ksh] This is a debug line [-d]
[INFO   ] 2009-02-03 14:16:30.000 [user001] [logging.ksh] logging with an '-i' for [INFO] type
[WARN   ] 2009-02-03 14:16:30.000 [user001] [logging.ksh] logging with an '-w' for [WARN] type
[ERROR  ] 2009-02-03 14:16:30.000 [user001] [logging.ksh] logging with an '-e' for [ERROR] type
[FATAL  ] 2009-02-03 14:16:30.000 [user001] [logging.ksh] logging with an '-f' for [FATAL] type

Essentially I've mimicked log4j, easy enough.

However, rather than go back thru X number of scripts and cut & paste the entire function script I've written into each one, is it possible to simply 'import/reference/inherit' this function (script) into each of the other scripts with a single line?

I'm using ksh to do all this. True, each script that needs to use this logging function will need to implement the proper "log [-diwef] <msg>" calls but I'd rather they do that and all refer to a single script that contains the function than bulk up 10+ scripts with lines and lines of the same code.

I have googled for this but so far nothing comes up with "AIX ksh scripting importing external script" and various of it.

Thanks!
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

external function in awk

Hi all, I have a basic doubt. Is there any way to use external functions (i.e. functions not defined in AWK), in AWK. I have a shell script in which I'm using a AWK snippet. In this snippet I'm calling a function defined in the shell script. But the AWK snippet is not working. I figured that... (5 Replies)
Discussion started by: kamel.seg
5 Replies

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

3. Shell Programming and Scripting

how to import external HASH table in PERL???

hello, I am creating a HASH table using file1.pl :- I want to retrieve the content of the hash table created above from another file named file2.pl :- The problem is that if I separate like this into 2 files.Then it says that HASH table is not created.So can you please tell me how to... (2 Replies)
Discussion started by: nsharath
2 Replies

4. Shell Programming and Scripting

Calling external function in a shell

hi guys, how r u??? please I need you, help me please. I have a shell, in this shell i have this function and another code lines, this function is getting date one day back. the function is in the same shell (FILE 1) Now I need put this function in another file (FILE 2) and calling... (4 Replies)
Discussion started by: acevallo
4 Replies

5. UNIX for Dummies Questions & Answers

Call external function

Is it possible to call a function from another script? Thanks (6 Replies)
Discussion started by: chrisjones
6 Replies

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

7. Shell Programming and Scripting

Problem in passing date to external function from perl script.

my $sysdate = strftime('%Y-%m-%d', localtime ); biDeriveByDate('Table_Str',$sysdate,\@lIndx,\@lResVals) In a perl script, when I'm trying to pass $sysdate to some external function it's not working since $sysdate is passed as a string mentioned above but my function is expecting a date value... (1 Reply)
Discussion started by: Devesh5683
1 Replies

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

9. 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
service(8)						      System Manager's Manual							service(8)

NAME
service - run a System V init script SYNOPSIS
service SCRIPT COMMAND [OPTIONS] service --status-all service --help | -h | --version DESCRIPTION
service runs a System V init script in as predictable environment as possible, removing most environment variables and with current working directory set to /. The SCRIPT parameter specifies a System V init script, located in /etc/init.d/SCRIPT. The supported values of COMMAND depend on the invoked script, service passes COMMAND and OPTIONS it to the init script unmodified. All scripts should support at least the start and stop commands. As a special case, if COMMAND is --full-restart, the script is run twice, first with the stop command, then with the start command. service --status-all runs all init scripts, in alphabetical order, with the status command. If the init script file does not exist, the script tries to use legacy actions. If there is no suitable legacy action found and COMMAND is one of actions specified in LSB Core Specification, input is redirected to the systemctl. Otherwise the command fails with return code 2. FILES
/etc/init.d The directory containing System V init scripts. ENVIRONMENT
LANG, TERM The only environment variables passed to the init scripts. SEE ALSO
chkconfig(8), ntsysv(8), systemd(1), systemctl(8), systemd.service(5) Jan 2006 service(8)
All times are GMT -4. The time now is 11:59 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy