Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
New to Linux Forums? Register here for free!
    Linux Forums > GNU Linux Zone > Linux Programming & Scripting > How do i check if a directory exists and display that it doesn't using bash?

Forgot Password?
 Linux Programming & Scripting   C, Perl, PHP, Bash Scripts, anything programming or script related post in here!

Site Navigation
Linux Articles
Linux Forums
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds


Linux Forum Topics
Linux Forums
Your Distro
Linux Resources
GNU Linux Zone
The Community
Closed Thread
 
Thread Tools Display Modes
Old 11-25-2005   #11 (permalink)
Trusted Penguin
 
Cabhan's Avatar
 
Join Date: Jan 2005
Location: Boston, MA, USA
Posts: 2,691
No problem with helping. I actually don't know much Bash myself, so it's a bit of a learning experience for me too. That's why I use Perl for everything .

Anyway, as far as that substring thing, no. Because you're doing (0,3), which, because 3 is exclusive, would return characters 0, 1, 2 ("tes"). You need to do "${word:0:4}".

Another way of thinking is that you start with the first number, and end right before the second number. So we start at 0, and end right before 4.
__________________
DISTRO=Gentoo
Registered Linux User #388732
Gentoo Linux, 410 GB HD, 1.2 GB RAM, Fluxbox, These are a Few of my Favorite Things
Cabhan is offline  


Old 11-25-2005   #12 (permalink)
Linux Enthusiast
 
Join Date: Jun 2005
Location: Odessa, FL
Posts: 586
Send a message via AIM to josolanes Send a message via MSN to josolanes Send a message via Yahoo to josolanes
Quote:
Originally Posted by Cabhan
No problem with helping. I actually don't know much Bash myself, so it's a bit of a learning experience for me too. That's why I use Perl for everything .

Anyway, as far as that substring thing, no. Because you're doing (0,3), which, because 3 is exclusive, would return characters 0, 1, 2 ("tes"). You need to do "${word:0:4}".

Another way of thinking is that you start with the first number, and end right before the second number. So we start at 0, and end right before 4.
ok, cool. i got it

thank you so much. i'm very close to getting it finished. now i just need to adjust the 2.6 section for 2.4, add if-then's for the bootloader that the person chooses, and add the code to add lines to the bootloader
josolanes is offline  
Old 11-25-2005   #13 (permalink)
Linux Enthusiast
 
Join Date: Jun 2005
Location: Odessa, FL
Posts: 586
Send a message via AIM to josolanes Send a message via MSN to josolanes Send a message via Yahoo to josolanes
ok...i finally finished writing it. i'm testing it now with a new kernel to see how it works and if there are any bugs

i'll start a new thread in "Linux Applications" with this program in it and what it does in detail tomorrow

thanks you very much for helping me write this
josolanes is offline  
Old 11-25-2005   #14 (permalink)
Linux Enthusiast
 
Join Date: Jun 2005
Location: Odessa, FL
Posts: 586
Send a message via AIM to josolanes Send a message via MSN to josolanes Send a message via Yahoo to josolanes
there was a small bug and i'm probably just going to avoid it. when it adds to grub/lilo, the entry is now placed too high (i didn't think about this earlier). it's added above the options at the top of the config files. so, i'll probably add it to the bottom instead and give the user the option of using the kernel if he or she wants by moving down to it...or maybe place it at the top but re-add the settings and make them the original grub/lilo defaults. i'm not sure yet. what would everyone rather have?
josolanes is offline  
Old 11-25-2005   #15 (permalink)
Linux Enthusiast
 
Join Date: Jun 2005
Location: Odessa, FL
Posts: 586
Send a message via AIM to josolanes Send a message via MSN to josolanes Send a message via Yahoo to josolanes
Quote:
Originally Posted by josolanes
there was a small bug and i'm probably just going to avoid it. when it adds to grub/lilo, the entry is now placed too high (i didn't think about this earlier). it's added above the options at the top of the config files. so, i'll probably add it to the bottom instead and give the user the option of using the kernel if he or she wants by moving down to it...or maybe place it at the top but re-add the settings and make them the original grub/lilo defaults. i'm not sure yet. what would everyone rather have?
ok...i decided to just add the new kernel to the bottom of the grub.conf/lilo.conf file, as i don't think i'll be able to place it where i want it. oh well. i'll post the code in the "Linux Applications" section soon. how would you all recommend i post this so that people can easily use it? i was thinking about just posting the code, but that would come up to 331 lines of code . is there a way for me to post just the program, to be dowlnoaded and readily executable?
josolanes is offline  
Old 11-25-2005   #16 (permalink)
Trusted Penguin
 
Cabhan's Avatar
 
Join Date: Jan 2005
Location: Boston, MA, USA
Posts: 2,691
Since I don't know Bash, I dunno if this is doable, but is it possible to read the file into an array until you reach the first actual kernel boot statement, then rename it, write the file that you read (the top statements) to the file, write the new kernel to the file, and then write the old one below that?

As far as posting the program, just put it online and link to it. That way, people can look at it and download it easily.
__________________
DISTRO=Gentoo
Registered Linux User #388732
Gentoo Linux, 410 GB HD, 1.2 GB RAM, Fluxbox, These are a Few of my Favorite Things
Cabhan is offline  
Old 11-25-2005   #17 (permalink)
Linux Enthusiast
 
Join Date: Jun 2005
Location: Odessa, FL
Posts: 586
Send a message via AIM to josolanes Send a message via MSN to josolanes Send a message via Yahoo to josolanes
Quote:
Originally Posted by Cabhan
Since I don't know Bash, I dunno if this is doable, but is it possible to read the file into an array until you reach the first actual kernel boot statement, then rename it, write the file that you read (the top statements) to the file, write the new kernel to the file, and then write the old one below that?

As far as posting the program, just put it online and link to it. That way, people can look at it and download it easily.
the first part confused me some, but i understand what you mean .
i don't know how to do arrays within bash....if i can find out how to, i would be willing to add that. it would make it a little bit easier to move from kernel to kernel (automatically would boot to it at restart). I found a nice site to look at regarding this (http://www.linuxvoodoo.com/resources...de/arrays.html) and am now reading through it to see how i would write the script

for posting the program, you mean use something like www.yousendit.com to host the file temporarily and post the link? that's the only way i know of doing this so far
josolanes is offline  
Old 11-27-2005   #18 (permalink)
Linux Enthusiast
 
Join Date: Jun 2005
Location: Odessa, FL
Posts: 586
Send a message via AIM to josolanes Send a message via MSN to josolanes Send a message via Yahoo to josolanes
OK...i've posted the program in the Linux Applications section. It runs perfectly from what I can see and I hope it is of some use to you

Link to thread
josolanes is offline  
Closed Thread


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

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 Off
Pingbacks are Off
Refbacks are Off

Free Magazines
Run Your Own Web Server Using Linux & Apache - Free 191 Page Preview
Learn about everything you'll need to build and maintain your Linux servers, and to deploy Web applications to them.
subscribe
Open Source Security Myths Dispelled
Dispel the five major myths surrounding Open Source Security and gain the tools necessary to make a truly informed decision for your IT organization
subscribe
InformationWeek
InformationWeek is the only newsweekly you'll need to stay on top of the latest developments in information technology.
subscribe



All times are GMT. The time now is 10:11 AM.






© 2000 - 2009 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.3.0 RC2