Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
Linux and Unix
Tag Cloud
access audio black screen blue screen boot bsod connection crash desktop driver drivers dvd email error excel firefox hard drive hardware hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem processor ram recovery registry cleaner router safe mode screen slow sound spyware trojan upgrade video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
scripting problem

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

Closed Thread
 
Thread Tools
AgentWalker's Avatar
Junior Member with 1 posts.
 
Join Date: Apr 2003
24-Apr-2003, 10:17 AM #1
scripting problem
Hi all go easy on me as im still getting the hang of this

iv got a 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.

Ic 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
Squashman's Avatar
Distinguished Member with 14,988 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
25-Apr-2003, 03:15 AM #2
But what if you wanted to merge files together from different directories at the same time. Wouldn't that be useful as well. If you checked for that to cause an error you would not be able to do that.
deuce868's Avatar
Senior Member with 638 posts.
 
Join Date: Nov 2000
Location: MI
25-Apr-2003, 01:00 PM #3
this might be a good place to start

http://www.tldp.org/LDP/abs/html/regexp.html
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
25-Apr-2003, 07:51 PM #4
One way (and far from the only way) to do this would be to echo each filename to be added to the "bundle" and pipe the output to grep/egrep/fgrep to search for the "/" character. If the output is non-NULL, the filename contains one or more "/" characters. If the output is NULL, the filename does not contain "/" characters.

Since you don't mention the scripting language you're using, I've assumed bash-compatible. Examples:

echo "/usr/bin/ls" | egrep "/" (produces /usr/bin/ls)
echo "holy regular expression Batman" | egrep "/" (produces no output)

The return codes from the two examples are also different -- another way to test the result.

Hope this helps.
__________________
The slowest component still sits at the keyboard.
Closed Thread Bookmark and Share

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Smart Search

Find your solution!



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.

Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 05:26 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.