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:

[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!

If you're using functions for your logging, you can import that file with '. <path/to/file>'
And I know it might be a bit late, but there is a Log4j variant for shell scripts, called Log4sh

Ah cool.. and.. damn! :slight_smile:

Thanks mate! Problem solved!