Computing.Net > Forums > Unix > Scripting Problem

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Scripting Problem

Reply to Message Icon

Original Message
Name: AgentWalker
Date: April 24, 2003 at 07:37:38 Pacific
Subject: Scripting Problem
OS: Unix
CPU/Ram: Unknown
Comment:

Hi all go easy on me as im still getting the hang of this

iv got a bash script that will bundle a few files together. to run it you enter somthing like this

bundle house home light > newfile

this will put the 3 files "house home light" together in the newfile.

I got it doing that but now need to add some error checking.

im trying to make the script detect if the user tries to add a "/" character in any of the parameters and if so output an error message.

how would i go about checking the parameters to see if they contain the '/' character ?

thanx all for your help


Report Offensive Message For Removal


Response Number 1
Name: David Perry
Date: April 24, 2003 at 09:45:23 Pacific
Reply: (edit)

Should it error out if one of the parameters is equal to '/' or also if it contains '/'.

cat /etc/host /etc/dhcpd.conf /etc/resolv.conf > cat.out

should be legal. You would want to make sure the user does not pass any directory as one of the parameters.



Report Offensive Follow Up For Removal

Response Number 2
Name: nails
Date: April 24, 2003 at 10:06:54 Pacific
Reply: (edit)

Walker:

I'm assming any slash is an error. The following tested under ksh and bash exits, but you don't have to:


for i in $*
do
# all on one line
echo "$i"|grep "\/" > /dev/null && echo " $i has a /" && exit 1
done

Regards,

Nails


Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge
Poll History




Data Recovery Software