What is a wrapper?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers What is a wrapper?
# 1  
Old 06-22-2010
Question What is a wrapper?

Hi,
I am a dummy and hear to the computation guys telling me,
"Oh! that is easy, you just write a wrapper to do all that bunch of stuff!" Smilie

Could someone tell me what is a wrapper? Smilie The only one I know is Cling-Wrap for sandwiches.

A small elegant example would be very appealing.
Thanks
~GH
# 2  
Old 06-22-2010
You use wrappers when you want to enhance the functionality of an existing utility/command without changing it (usually for backwards compatibility or because you don't have access to the original source code).

An alias is the simplest form of wrapper. You can create the following alias to always get a long listing from the output of ls:
Code:
alias ls='ls -l'

A more complex example could be, lets say, you have a command which processes some sort of message passed as a command line argument:

Code:
process_msg "this is a message"

Now, you want a functionality to pass a file with bunch of messages to be processed. You can write a wrapper which utilizes the existing process_msg utility to process multiple messages:

Code:
function process_file
{
  file=$1
  cat $file | while read msg
  do
    process_msg "$msg"
  done
}
process_file input.dat

Hope that explains!
This User Gave Thanks to a_programmer For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

Wrapper functions like SuSEFirewall2

Hey everyone, I have a question. I'm administering a linux machine that runs openSuSE. A few of the functions that I'd normally do manually, have programs that take over the task. For example, I wanted to add a few rules to my iptables. I then found out that there is an openSuse tool... (3 Replies)
Discussion started by: Lost in Cyberia
3 Replies

2. Shell Programming and Scripting

Help needed on wrapper script

Hi Gurus, I need to build a wrapper script which will be passing the loading date and the data file name (provides option to the user to load a single data file or load all the data files) to the actual loader data_load.ksh to load in the database. 1. I want to execute the loader script... (6 Replies)
Discussion started by: express14
6 Replies

3. Shell Programming and Scripting

Count script wrapper help

I have this a code that I got help with for another task. I since tried to modify it to work on this task. I need someones expertise to modify it slightly and I am not sure where to start or yet fully understand the logic. I am trying to get a script to read my m-names.txt which has lots... (19 Replies)
Discussion started by: richsark
19 Replies

4. Shell Programming and Scripting

wrapper script in perl

Hi, I am in need of way to facilitate this senerio in a perl script. I have CLI ( command line interface) which I run like so: kip-tepltist -u Xxx -p Xxx Which produces tones of names from each template it found: 194Iselin-NJ 33-IDFLB-North-611-Woodward-8600 ... (5 Replies)
Discussion started by: richsark
5 Replies

5. UNIX for Dummies Questions & Answers

SSH/SSL wrapper

My IRC client does not support SSL, so I was wondering if there was any other way to encrypt the information between SSL clients on an IRC network, maybe by using SSH to enter the IRC program or something (it's a command-line program) and passing all the plain-text through SSH first. I tried... (0 Replies)
Discussion started by: guitarscn
0 Replies

6. Shell Programming and Scripting

Help with a wrapper script not working

Hello, I have the below wrapper script: #!/usr/bin/perl -w if ($^O eq 'MSWin32' ) { $subnet = 'c:\path\to\subnet.txt'; } else { $subnet = '/opt/qip/wrapper-del-sub'; } open FH1, 'jj-deleted-subnets.txt' or die "Can't open 'jj-deleted-subnets.txt' ... (0 Replies)
Discussion started by: richsark
0 Replies

7. UNIX for Dummies Questions & Answers

Writing a wrapper

Hi everyone, I have this custom sudo package over which I want to write a wrapper using PERL. The wrapper will do some pre-work and then call the regular sudo package from within itself. But I am facing a peculiar problem here. Once invoked, I am able to do the pre-work from within the... (1 Reply)
Discussion started by: garric
1 Replies

8. UNIX for Dummies Questions & Answers

What is a wrapper script

I tried searching the forum ,,but couldn't locate ..Can anyone give me a link or some information about wrapper script. (1 Reply)
Discussion started by: thana
1 Replies

9. UNIX for Dummies Questions & Answers

What is wrapper script and how to write

hi guys, I have a requirement to run a script 4 times with different parameter values. the 4 jobs have to run parallely which actually access different data of same table and deletes. how can i achieve this.................? Thanks in advance (1 Reply)
Discussion started by: chiru
1 Replies

10. UNIX for Advanced & Expert Users

Tcp wrapper

I installed tcp wrappers version 7.6 and modify my inetd.conf file from ftp stream tcp6 nowait root /usr/sbin/in.ftpd in.ftpd to ftp stream tcp6 nowait root /usr/local/bin/tcpd /usr/sbin/in.ftpd -l created /etc/hosts.allow file and modify it... (19 Replies)
Discussion started by: hassan2
19 Replies
Login or Register to Ask a Question