- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Input Parameters
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
Discussions
Discussions
Forums
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
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-17-2005 04:46 AM
тАО08-17-2005 04:46 AM
I'm a newbie at scripting and I'm trying to write a script that will examine each argument passed and report whether the argument is a directory, link, other or does not exist. If no arguments are passed I want to print out the usage statement.
All I have at this point is:
USAGE="usage:param.ksh arg1 arg2 arg3"
I am litterally drawing a blank. Any guidence would be much appreciated.
thanks,
diesel
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2005 04:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2005 04:56 AM
тАО08-17-2005 04:56 AM
Re: Input Parameters
# file -h file1 file2
Is this, what you want?
HTH!
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2005 04:58 AM
тАО08-17-2005 04:58 AM
Re: Input Parameters
# file -h `ls`
Hope this helps!
Regards
Torsten.
__________________________________________________
There are only 10 types of people in the world -
those who understand binary, and those who don't.
__________________________________________________
No support by private messages. Please ask the forum!
If you feel this was helpful please click the KUDOS! thumb below!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2005 04:59 AM
тАО08-17-2005 04:59 AM
Re: Input Parameters
#!/usr/bin/sh
typeset PROG=${0}
typeset -i STAT=0
if [[ ${#} -ge 1 ]]
then
while [[ ${#} -ge 1 ]]
do
typeset F=${1}
shift
echo "${F} \c"
if [[ -e "${F}" ]]
then
if [[ -f "${F}" ]]
then
echo "regular file"
fi
if [[ -d "${F}" ]]
then
echo "directory"
fi
if [[ -h "${F}" ]]
then
echo "symbolic link"
fi
else
echo "does not exist"
fi
done
else
echo "Usage: ${PROG} arg1 [arg2 ...]" >&2
STAT=255
fi
exit ${STAT}
- Tags:
- Test
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2005 05:02 AM
тАО08-17-2005 05:02 AM
Re: Input Parameters
if [ $# -lt 1 -o \( $# -gt 1 -a $# -lt 4 \) ]
then
echo "Usage:"
echo "usermem \"userid\""
echo "Example:"
echo "usermem gwild"
exit 1
fi
echo " "
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2005 05:04 AM
тАО08-17-2005 05:04 AM
Re: Input Parameters
is a,b,c,etc.) described in the sh-posix
man page.
for item
in $*
do
[[ -f $item ]] && echo "$item is a file"
[[ -d $item ]] && echo "$item is a dir"
etc.
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2005 05:06 AM
тАО08-17-2005 05:06 AM
Re: Input Parameters
I appreciate all your rapid responses. All of you have something I can use so thank you so much.
-diesel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2005 05:15 AM
тАО08-17-2005 05:15 AM
Re: Input Parameters
#!/usr/bin/sh
set -u
export PATH=/usr/bin
MYNAME=${0##*/}
if [ $# -lt 1 ]
then
echo "\nUsage: $MYNAME arg1 [...arg2...]\n"
exit
fi
# Now run through each parameter
for MYARG in $@
do
if [ -f $MYARG ]
then
echo "$MYARG is a file"
elif [ -d $MYARG ]
then
echo "$MYARG is a directory"
elif [ -h $MYARG ]
then
echo "$MYARG is a symbolic link"
else
echo "$MYARG does not exist or is some other filetype"
fi
shift
done
Of course you can adjust the code to meet your needs.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-17-2005 05:27 AM
тАО08-17-2005 05:27 AM
Re: Input Parameters
These forums are great!!
-diesel