how to create a simple script for installing a list of files
DebianThis forum is for the discussion of Debian Linux.
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.
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.
how to create a simple script for installing a list of files
I come from a dos backround and am used to createing batch sripts. usually anything that can be typed at the prompt can be put into a batch script and executed. I guess my question would be
Is there any program in linux that does somthing similar to this?
I tried createing a sript with bash but could not get it to work
the script was to install a list of files to install xwindow and a window manager
If I were to execute each one of these commands at the prompt manually I could install each one but that takes forever faster to automate it witha script
This is actually a scriptrequest and I doubt that's allowed, no matter how well founded your reasons are. Anyway, Bash is an excellent choice for scripting, as it's way more powerful then Dos
Regarding what you wanted to achieve: Debian's package system is way superior to any other in ICT. If you want to install a certain package, apt (the underlaying engine) is so smart it finds, selects, marks and downloads dependencies w/o you needing to specify them.
when I executed the script it would throw me errors to the effect it could not find the archives no such file or somthing I put it int the same directory as the files so it should have found them
Your script could have various uses, but your example isn't very good.
To install xwindows and a desktop or window manager, one would normally do it in one command, not a series of commands.
e.g. # aptitude install xserver-xorg-core xserver-xorg xorg gdm gnome-core gnome-utils
...and whatever other pieces you have in mind.
I realize there are better or rather different methods but On my debian 2.1 slink i have not been able to get apt to work and dselect is hopelessly broken. It refuses to install anything from the hard drive to explain the erors would take up far to much space here. I have worked with ubuntu and its the same so I have had to come up with my own methods for doing tasks like this one.
as far as this not being a very good example I am sorry but I have to do what i have to do I am gropeing in the dark takeing what I do know and going with it this is the best i could come up with and should have worked I am just trying to understand why it is not.
Debian 2.1 is hopelessly outdated, only yesterday Debian 4.0 came out. In your case I'd have to suggest re-installing from scratch (after you've saved your data on an optical disk or to another machine)
This is actually a scriptrequest and I doubt that's allowed, no matter how well founded your reasons are. Anyway, Bash is an excellent choice for scripting, as it's way more powerful then Dos
Regarding what you wanted to achieve: Debian's package system is way superior to any other in ICT. If you want to install a certain package, apt (the underlaying engine) is so smart it finds, selects, marks and downloads dependencies w/o you needing to specify them.
Why is this not allowed is there some secret and what could be the reason for that I thouhgt this was open source. whats your definition of that.
as far as bash being more powerfull that may be but the documentation for trying to figure out how to use it is very lousy and I put extreeme emphasis ont the lousy.
Again if debians package system is so superior why cant it install from a copy on the hard drive. if it can than whats the reason for sending out a broken program that does not work. Or better yet why the secret for the meathod of installing another way if it can.
Debian 2.1 is hopelessly outdated, only yesterday Debian 4.0 came out. In your case I'd have to suggest re-installing from scratch (after you've saved your data on an optical disk or to another machine)
Oh really then how do you explain why ubuntu which is based on debian does the same thing getting another half baked distro to do the job seems to me to be a little redundant for lack of a better word
Bashing people around doesn't help your favor ratings here Debian 2.1 is old, and since long not supported anymore. The reason Ubuntu doesn't install your Debian 2.1 packages is just that: it's another distro! Would you use Suse to install Mandriva packages as well? They're both rpm-based you know...
You mentioned the word lousy. I'm sorry, but Debian isn't lousy, it's you. Stuck in the (limited and confined) world of DOS and not able (or willing) to look over the edge and actually try what's suggested...
Unless you change your attitude I doubt you're gonna get much help here. After all, all of us are doing this because we choose to spend our spare time helping people, not 'cause we're paid to do so...
Bashing people around doesn't help your favor ratings here Debian 2.1 is old, and since long not supported anymore. The reason Ubuntu doesn't install your Debian 2.1 packages is just that: it's another distro! Would you use Suse to install Mandriva packages as well? They're both rpm-based you know...
You mentioned the word lousy. I'm sorry, but Debian isn't lousy, it's you. Stuck in the (limited and confined) world of DOS and not able (or willing) to look over the edge and actually try what's suggested...
Unless you change your attitude I doubt you're gonna get much help here. After all, all of us are doing this because we choose to spend our spare time helping people, not 'cause we're paid to do so...
In short: straighten up or go somewhere else.
for one thing I was not trying to install debian pakages with ubuntu. I want to copy my distro cd rom to a hardisk logical partition and have it do the install from there. Neither of these distros will do that dselect is very broken and there does not seem to be any documentation for another way. It seems that there were some verious kludges put into these distros for what perpose I dont know Iam just trying to get a working operateing system of my own
second I came up with this script becouse I found that I could manually go through all the files and install one at a time but when put in the script and executed it could not find the files and there for could not install. was trying to understand why?
and I did not say debian was lousy only the documentation for firgureing things out
as for bashing people around I am sorry it came out that way but if you had stuck to the main idea of the thread rather than giveing me your opion about the why and what you think then we would have made more progress
i readed it all and still not understanding why to use packages out of the box....
but the hint i can give you is
- there's a variable called $? that is the output of every program to the standart output: by default is 0 (sucess) or not 0 (error)
- debian package manager handles a lock system to prevent several packages to be installed simultaneously.. i guess it is at /var/lock/<something> (handle with care)
so.. i sugest somthing like this.. (requires some editing)
Code:
#!/bin/bash
# this is a comment
# what's bettween "`" means the result of the command...
# ex: "echo `uname`" have the same effect of "echo Linux"
dpkg -i package
# waits until the package is installed
while [ `cat /var/lock(..)`=value] ; # while package is installed...
do
sleep 0.5 # wait 0.5 second and retest the value
done
if ["$?"="0"]; then
echo "Package installed sucessfully"
else
echo "errors occured"
fi
I only use debian since woody.. i don't know if what i said is valid for slink
thank you Nuno I shall try this and get back if nothing it gets me further ahead in understanding this process.
ps
I am not sure I understand the question?
readed it all and still not understanding why to use packages out of the box....
Uh do you mean why not to use packages out the box or to use source or somthing other than box packages ?????????
no matter realy its just an experiment if I can get it to work with this I should be able to expand it further with other files and packages that need to be installed from a logical partition on my hard drive
hey it works
this has realy expanded my horizons I had read through the abs-howto before and could not find anything that made any sense i realize now it was my vague understanding of bash programing thanks to your small script it makes a little more sense to me now
although i still do not find anything that resembles the $? thing in the howto or the
[ `cat /var/lock(..)`=value] ;
still unclear as to why that has to be but thats just me i understand what is there a lttle better anyway
I think this should be included in the abs howto what do you think
I modified the script a little to include some convienences here are my edits
#!/bin/bash
clear # to clear the screen so as to view the output
# this is a comment
# what's between "`" means the result of the command...
# ex: "echo `uname`" have the same effect of "echo Linux"
# waits until the package is installed
while [ `cat /var/lock(..)`=value] ;
# while package is installed...
do
sleep 0.5 # wait 0.5 second and retest the value
done
if ["$?"="0"]; then
echo "Package installed sucessfully"
else
echo "errors occured"
fi
exit 0 # to avoid the unexpected end of file error
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.