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 acer asus bios bsod computer crash driver drivers error ethernet excel freeze gaming google gpu graphics hard drive hardware hdmi internet laptop malware memory monitor motherboard mouse network printer problem ram registry router server slow software sound svchost.exe trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > Linux and Unix >
scripting problem

Reply  
Thread Tools
AgentWalker's Avatar
Junior Member with 1 posts.
 
Join Date: Apr 2003
24-Apr-2003, 11: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
Trusted Advisor with 18,705 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
25-Apr-2003, 04: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, 02: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, 08: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.
Reply

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.

Search Tech Support Guy

Find the solution to your
computer problem!




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



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 04:59 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.