Wrapper Scripts And Its Uses

Explain what is wrapper script, and where they use it.

A wrapper is another script to "wrap around" existing script/s to do any of the following: 

1) To control the execution of the main script/s (set environment variables, set aliases, etc). 

2) To provide more information about the execution of the base script/s (display the time of execution, dump output to a log file, display the return code of the execution of the base script/s,  etc). 

3) Create a single point of entry to manipulate multiple scripts (For example, a simple script that displays Menu Options that will execute other scripts can be considered as a wrapper script). 

A wrapper script is a script that has got a bunch of other scripts and commands in them. 

A normal script will have stuff like: 

ls 

cp 

while true 

date 

echo 
 

A wrapper script will refer to other scripts: 

/admin/check_precesses.sh 

if [ $? != 0 ] 

then 

echo "Checking of processes failed" 

exit 7 

else 

/admin/report_processes.sh 

fi 
 

Wrapper scripts are also used to capture all output of another script or scripts to a log file. 

A wrapper script is a master script which controls the execution of other scripts. 

For example- 

You have some scripts called A.sh, B.sh and so on... 

Now you have to run this scripts for a particular task one after another. Manually it would be a cumbersome task. So what you can do is write a wrapper around this scripts (also a script) which controls the execution of this scripts without the need to run them manually. 

It all depends upon the circumstances.

Unix Tips

See Also
Shell Script For Deleting Files

Have a Unix Problem
Do you have a UNIX Question?

Unix Books :-
UNIX Programming, Certification, System Administration, Performance Tuning Reference Books

Return to : - Unix System Administration Hints and Tips

(c) www.gotothings.com All material on this site is Copyright.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
All product names are trademarks of their respective companies.
The site www.gotothings.com is in no way affiliated with or endorsed by any company listed at this site.
Any unauthorised copying or mirroring is prohibited.