Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
08-01-2005, 05:10 AM
|
#1
|
Member
Registered: Jun 2005
Location: Oslo, Norway
Distribution: Slackware 11, Solaris 10, Solaris 9, Sourcemage 0.9.6
Posts: 322
Rep:
|
Reading a conf file from a BASH script
Hi!
I'm a BASH newbie. I have to write a script for a project I'm working on, but I have no BASH book or manual.
Ok, this is my problem:
I want to read a config file I made myself. How do I make BASH read it and execute the commands in it? The file already contains a URL. Do I have to make another file or can I use the same as the URL's?
Hope this isn't a too stupid question 
|
|
|
08-01-2005, 06:34 AM
|
#2
|
Member
Registered: Jan 2004
Location: Duesseldorf /Germany
Distribution: Gentoo amd64 / Debian
Posts: 226
Rep:
|
Start here:
http://www.tldp.org/LDP/abs/html/
As a hint:
Define a config file (config.txt) like this:
Code:
URL=http://test.com
NUM_TRIES=10
MSG=test it
Now, to use these values, put the folowing code in your script:
Code:
. config.txt
wget $URL
echo "not trying anything yet, I need to rite a loop for $NUM_TRIES tries"
echo $MSG
The first line here "sources" the config file.
That means that all varables declared in your config file are available in your script.
That's it,
|
|
|
08-01-2005, 10:16 AM
|
#3
|
Member
Registered: Jun 2005
Location: Oslo, Norway
Distribution: Slackware 11, Solaris 10, Solaris 9, Sourcemage 0.9.6
Posts: 322
Original Poster
Rep:
|
Thanks a lot! The script now reads the config file without problems.
But I got a different problem now:
The script is supposed to download and unpack archives, but when it unpacks I get this error:
Code:
bzip2: Compressed file ends unexpectedly;
perhaps it is corrupted? *Possible* reason follows.
bzip2: Inappropriate ioctl for device
Input file = (stdin), output file = (stdout)
It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.
You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.
tar: Child returned status 2
tar: Error exit delayed from previous errors
How do I fix this one???
|
|
|
08-03-2005, 02:14 AM
|
#4
|
Member
Registered: Jan 2004
Location: Duesseldorf /Germany
Distribution: Gentoo amd64 / Debian
Posts: 226
Rep:
|
Soryy, but:
how am I supposed to know?
You did not post your script.
You did not describe what steps are taken.
You did not post the exact command with parameters that led to the error?
Do you Think I'm psychic? :-))
More info => More answers.
|
|
|
08-03-2005, 05:17 AM
|
#5
|
Member
Registered: Jun 2005
Location: Oslo, Norway
Distribution: Slackware 11, Solaris 10, Solaris 9, Sourcemage 0.9.6
Posts: 322
Original Poster
Rep:
|
I resolved the unpacking problem. Everything is fine. The problem was that it saved at least 10 copies of the same file and then it couldn't unpack them correctly. Anyway you have been great help thank you a lot.
Hope to see you again 
|
|
|
08-03-2005, 05:18 AM
|
#6
|
Member
Registered: Jun 2005
Location: Oslo, Norway
Distribution: Slackware 11, Solaris 10, Solaris 9, Sourcemage 0.9.6
Posts: 322
Original Poster
Rep:
|
I resolved the unpacking problem. Everything is fine. The problem was that it saved at least 10 copies of the same file and then it couldn't unpack them correctly. Anyway you have been great help thank you a lot.
Hope to see you again 
|
|
|
All times are GMT -5. The time now is 03:48 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|