Shell Script Dependency/Tracer


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Shell Script Dependency/Tracer
# 8  
Old 03-12-2008
You could do it by parsing: There are only so many methods of invoking external commands:

$(command)
command | command
`command`

These constructs can be extracted from every script with some sed-script. Get the "command" part out of the found pieces and apply a "file" command on each. If the result is "executable" or "object module" or similar you can throw it away, if the result is "shell script" you have found one candidate.

This way you get a list of all the shell scripts a script invokes. Create a list for every script and you have your tree.

I hope this helps.

bakunin
# 9  
Old 03-12-2008
Question

Quote:
Originally Posted by ag79
Thanks jgt and ShawnMilo.

jgt: he solution will work, and I'm exploring this option.

ShawnMilo: Your solution is similar to shamrock's conceptually. I'm slightly wary of this solution because it'll involve a lot of manual work. Thanks anyway!

At this stage I'm also exploring the option of actually executing the code and capturing trace (only to EXEC and FORKs) on unix level, to see what scripts get exec'd, which will in effect tell me what commands got executed by shell(s)

I again thank everyone for reading and specially to those who took out time to reply.
Anyway,this is a good question which will be helpful in the analysis phase of a lot of enhancement projects.So i request you to post the solution you applied(either extracted from the replies or from some other ref - the working code).

With Regards
Dileep Pattayath
# 10  
Old 03-12-2008
I don't think the idea I presented requires any manual work. Write short script to add the line I suggested to each script. Nothing manual there.

Parse the log file using command-line tools. Nothing manual there.

Of course, I could always be missing some important point you were trying to make, or I might not have been clear enough in my post. If the idea still doesn't work for you, please post the reason, or let us know what you end up doing.

Thanks,
ShawnMilo
# 11  
Old 03-12-2008
Shawn,
You are assuming that all the scripts will be called in a reasonably short time frame (what about scripts only run at year end?)
There are also other issues that I have considered since my last post:
What about dynamic calls:
if .....
a=1
else
a=2
fi
abc$a

What about scripts called from within application code, and do you have the source code for this.
# 12  
Old 03-14-2008
Jgt's point is valid one. What about scripts which are called from CRON or any other schedulers?
# 13  
Old 03-14-2008
Hello All,

Fortunately in the system that I'm working on, I know all the scripts that are scheduled using the various scheduler apps, or are manually executed, so I know all the "starting points". None of the scripts of my concern get executed from the application code or called dynamically.

Shawn - I agree what you worte, this can be done automatially, but I just didn't want to modify a huge number of scripts for getting this information.

Under the circumstances, the solution I have opted for is a hybrid one (its not the only solution, and it may not be the best one) , composed of :
1. "trace", as I wrote in one of my earlier post - command:
trace -h -a -d -k $IGNORE -o /tmp/my_trace_log; trcon; SCRIPT_NAME ; trcoff; trcstop

and make the report by

trcrpt -O "exec=on,pid=on,timestamp=3" /tmp/my_trace_log > my_trace_log.rpt

$IGNORE practically contain ALL the categories mentioned in trchkid.h (see man page of trace) except those of FORK and EXEC. A lot of EXECs need to be grepped out from the final report, and I have what I'm looking for!

2. Another combination of solutions suggested above - I have certain scripts that I need to move from one directory to another and thus see what other scripts will be impacted due to hardcoded paths, so I wrote a fancy grepp to look through the whole filesystem limiting the searched files to "ascii text" files and "*Scripts*" (using command "file"). Sucked the life out of the box!

I have been able to pull out the information I required using the above approach.

I would like to emphasise that this solution may or may not work for all, and is certainly not covering all the scenarios. It does work for me, so I'm sharing it for everyone who took time to think about this problem.

Once again, thanks all!
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Processing Dependency Printing

Gurus, I came across a typical requirement where the input is like- TRANS FIRM DEPT CUST TRANS CUST TRANS DEPT FIRM CUST & the expected Output is- CUST DEPT FIRM TRANS This is basically a dependency list for processing the tables where FIRM is feeding data to TRANS... (3 Replies)
Discussion started by: kapeeljoshi
3 Replies

2. HP-UX

Library dependency coming out of nowhere

I'm building on a HP-UX ia64 system. During building, I'm getting an error ld: Can't find dependent library "libnnz10.so" Nowhere in my makefile do I link with this library. This library is there in the directory /databases/oracle10.2.0_64BIT/lib. I'm having two source files ora8ibulk.cpp... (1 Reply)
Discussion started by: old_as_a_fossil
1 Replies

3. UNIX for Dummies Questions & Answers

make -j dependency

Hi, I had a make file, something like that, all: cd dir1; make cd dir2; make the problem is the makefile under dir2 need some objs from dir1, so I need to set some dependency let dir2 run only after the dir1 run is done. how to set the dependency? Thanks. peter (2 Replies)
Discussion started by: laopi
2 Replies

4. Programming

Fortran dependency checking

Hello, I'm creating an add-on for a large piece of software written in Fortran. In my directory I reference subroutines in other directories, which in turn reference more subroutines. I'm running into trouble because on occasion the developers of the main software change some sub calls. ... (2 Replies)
Discussion started by: kudude
2 Replies

5. Post Here to Contact Site Administrators and Moderators

Tynt Tracer Must Die

First of all, I want to thank everyone who runs this forum for the fine job they've done. While I myself have not yet had any need for help, I have enjoyed and learned while helping others. Due diligence disclaimer: I searched for a discussion on this issue, using "tynt" and "copy paste", but... (11 Replies)
Discussion started by: alister
11 Replies

6. Infrastructure Monitoring

Weird dependency problem!

Hi, I want to install net-snmp-devel package but i have following dependecy problem. It's very odd, i don't get it. One of packages is depended on the other one, the other one is depended on the previous one as well. :S :S Could you help me please? Here are the steps: # ls -l total... (4 Replies)
Discussion started by: oduth
4 Replies

7. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

8. Solaris

Dependency problem

Hi all am new to solaris ............ i installed amanda client pkg that time am getting lots of dependency problem.......... is there any Yum server like things in solaris Regards ' prAn (8 Replies)
Discussion started by: pran
8 Replies

9. UNIX for Dummies Questions & Answers

process dependency

how to find all the processes associated with a given process in unix,is there any command for this. (3 Replies)
Discussion started by: laddu
3 Replies
Login or Register to Ask a Question