Suppose I have a program P11 in a directory; it calls 2 other programs P21 & P22. Each of P21 & P22 call 2-2 other programs.
Level-1: |--------------P11-------------| Level-2: |--------P21----------| |----------P22----------|... Level-3: P31 P32 P33 P34... . . . . . . . .
Just like a tree diagram having 100s of levels, 100s of nodes at each level and 1000s of nodes in total.
I need a shell script which will give me such a tree structure.
e.g. The shell script program is – ‘
It takes a parameter at runtime. We can provide a program name here e.g. P11. And the script gives such a tree diagram.
Not necessary that the output structure should be in such a diagram like format as given above. We can use indexing or anything you suggest. e.g. The output file could be as –
1. P11 1.1 P21 - 1.2 P22 1.1.1 P31 - 1.1.2 P32 – 1.2.1 P33 – 1.2.2 P34
i.e. Every program's index = it's parent's index + "." + its serial number in that parent program.
Just the thing is – the number of levels & number of nodes in each level is unknown, but very large.
The program syntax used to call another program is as below.:
Command to find the children programs in a given program is as below.:
egrep '^CALL| CALL ' $pgm_name > call_output | cut -d'"' -f2 call_output > call_output_cut | cat call_output_cut
I am stuck at - how to loop this command to get the above stated output file.
Can anybody suggest something?