- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Shell Script : Wrapper
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2000 07:52 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-16-2000 08:42 PM
08-16-2000 08:42 PM
SolutionFor example a really simple ftp wrapper script could get the username and time of everyone using the ftp command.
#!/bin/sh
LOGFILE=/var/adm/ftp/ftp.log
echo "`whoami` on `uname -n` opts : $@ nStart ftp : `date`">> $LOGFILE
/usr/bin/ftp $@
echo "End ftp : `date`">> $LOGFILE
echo "n">> $LOGFILE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2000 01:18 AM
08-17-2000 01:18 AM
Re: Shell Script : Wrapper
A wrapper script is one which is written to call another script/program, but the wrapper now allows you to control the environment by setting things like environment variables, paths, output, errors etc.
eg. if you have a simple script called say daily_backup then to put a wrapper around it you could write another script which then calls daily_backup, eg;
#!/bin/sh
ERRORLOG=/tmp/daily_backup.error
LOG=/tmp/daily_backup.log
daily_backup > $LOG 2> $ERRORLOG
RETURN_CODE=$?
if [ $RETURN_CODE -ne 0 ]
then
echo "daily_backup failed, return code=$RETURN_CODE" >>$ERRORLOG
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2000 05:30 AM
08-17-2000 05:30 AM
Re: Shell Script : Wrapper
"To find a file, use find / ..."
Unfortunately, this could take hours on a 500 Gbyte system, affecting every user on the system by issuing directory searches on every mounted disk. If there are NFS mounted disks the task also hits the network very hard.
I put a wrapper on find to prevent this newbie-type error:
--
#!/usr/bin/sh
#
# Replace find with a wrapper
#
if [ $1 = "/" ]
then
echo
echo "DO NOT USE: find /"
echo "It will affect every user on the system."
echo "Please search specific directories"
exit 1
fi
exec /usr/bin/find.real "$@"
--
Create this script with the name: find
Then rename /usr/bin/find to /usr/bin/find.real and move the script called find to /usr/bin. Make sure it is executable (chmod 755 /usr/bin/find).
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2000 06:10 AM
08-17-2000 06:10 AM
Re: Shell Script : Wrapper
Certainly the above posts provide very good examples of wrappers.
Consider too, that another use of wrappers is to be able to call a "super" script (or other piece of code) which requires a large number of arguments with a minimum of arguments. This is a user convenience. For instance, rather than, having to pass the filesystem type as on argument to a hypothetical super script, several wrapper scripts are created -- one for hfs, one for vxfs, etc. The wrappers are named to denote their intended filesystem targets.
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-17-2000 08:50 AM
08-17-2000 08:50 AM