There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
UNIX/Linux
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > UNIX/Linux >
scripting problem


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
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 12,604 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
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.
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

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 08:29 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.