- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- problem with writing a 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
Forums
Discussions
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
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
02-18-2003 10:38 AM
02-18-2003 10:38 AM
I'm writing a wrapper for crontab command like below:
--------------------------------------------
#!/usr/bin/sh
#
# Replace crontab with a wrapper
# Written by M.B.
#
if [ `expr index "$1" "[\*,\?]"` -ne 0 ]
then
echo "Usage: crontab -l | -v | -r | -e [username]"
exit 1
else
exec /usr/bin/crontab.orig "$@"
fi
-----------------------------------------
But I have a problem,
when passing parameters to the script for example like "*a", if there is a file name ending with a (e.g baa), $1 value is "baa" not "*a", or another example,
let say that parameter is ?l, and if there is a file named ll, then $1 value is "ll" not "?l"!
I want to see the real values of the parameters in order to check if there is an incorrect value in the parameter.
How can I solve this problem?
Urgent!!!
Best regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2003 10:43 AM
02-18-2003 10:43 AM
Re: problem with writing a wrapper
crontab '*a'
This will prevent the shell from expanding the wildcard. You may also use the backslash, ie
crontab \*a
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2003 10:48 AM
02-18-2003 10:48 AM
Re: problem with writing a wrapper
groups all your args together to one single arg. Drop the (double) quotes.
I also dislike the use of 'else' after exit/exec, because it will never be executed as such
if [ $# -lt 1 -o `expr index "$1" "[\*,\?]"` -ne 0 ]; then
echo "Usage: crontab -l | -v | -r | -e [username]"
exit 1
fi
exec /usr/bin/crontab.orig $@
Enjoy, have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2003 10:59 AM
02-18-2003 10:59 AM
Re: problem with writing a wrapper
Thanks very much for your answers.
Procura, I corrected the mistakes, thanks.
Rodney,
I have still the problem.
You wrote that I can use
"crontab \*" etc.
Yes I know it, but my users don't know. They can write crontab *l by mistake and they lose their original crontab file.
Therefore I want to prevent them doing mistakes by a wrapper.
But how can I pass a parameter including * or ?to the $1 like it's original value?
Thanks very much!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2003 11:24 AM
02-18-2003 11:24 AM
Re: problem with writing a wrapper
This way the user input can be controlled.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2003 11:40 AM
02-18-2003 11:40 AM
Re: problem with writing a wrapper
:))),
Rodney, I agree with you but this still doesn't change the fact that I must do this.
Best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2003 11:41 AM
02-18-2003 11:41 AM
SolutionLook, how the echo command is called:
$ echo .pro*
.profile
$ set -f
$ echo .pro*
.pro*
Best regards...
Dietmar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2003 11:46 AM
02-18-2003 11:46 AM
Re: problem with writing a wrapper
I agree, your solution is probabily the best.
Now as long as the user don't use some of the other "special" shell characters (like #, $, etc) they should be ok.... :-)
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2003 12:10 PM
02-18-2003 12:10 PM
Re: problem with writing a wrapper
I'll try it.
Thanks all the others for their effort.
Best regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-18-2003 12:15 PM
02-18-2003 12:15 PM
Re: problem with writing a wrapper
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2003 02:32 AM
02-19-2003 02:32 AM
Re: problem with writing a wrapper
I can disable the wildcards file naming with using "set -f" command,
but how can I enable it again?
Thankss
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-19-2003 02:42 AM
02-19-2003 02:42 AM