LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 04-08-2007, 06:51 PM   #1
zbenjudah
Member
 
Registered: Mar 2006
Posts: 64

Rep: Reputation: 15
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

#!/bin/bash

dpkg -i file.deb
dpkg -i file.deb
dpkg -i file.deb
dpkg -i file.deb
dpkg -i file.deb
dpkg -i file.deb
dpkg -i file.deb
dpkg -i file.deb

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
 
Old 04-08-2007, 08:00 PM   #2
dxqcanada
Member
 
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702

Rep: Reputation: 43
What exactly happened with your script ??
 
Old 04-08-2007, 08:09 PM   #3
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 62
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.
 
Old 04-08-2007, 08:10 PM   #4
Dutch Master
Senior Member
 
Registered: Dec 2005
Posts: 1,686

Rep: Reputation: 124Reputation: 124
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

Useful links for a newbee:
http://tldp.org/
http://www.ss64.com/bash/

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.
 
Old 04-09-2007, 10:44 AM   #5
zbenjudah
Member
 
Registered: Mar 2006
Posts: 64

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by dxqcanada
What exactly happened with your script ??
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
 
Old 04-09-2007, 10:55 AM   #6
zbenjudah
Member
 
Registered: Mar 2006
Posts: 64

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rickh
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.

Last edited by zbenjudah; 04-09-2007 at 11:00 AM.
 
Old 04-09-2007, 11:10 AM   #7
Dutch Master
Senior Member
 
Registered: Dec 2005
Posts: 1,686

Rep: Reputation: 124Reputation: 124
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)
 
Old 04-09-2007, 11:15 AM   #8
zbenjudah
Member
 
Registered: Mar 2006
Posts: 64

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Dutch Master
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

Useful links for a newbee:
http://tldp.org/
http://www.ss64.com/bash/

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.
 
Old 04-09-2007, 11:21 AM   #9
zbenjudah
Member
 
Registered: Mar 2006
Posts: 64

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Dutch Master
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
 
Old 04-09-2007, 11:45 AM   #10
Dutch Master
Senior Member
 
Registered: Dec 2005
Posts: 1,686

Rep: Reputation: 124Reputation: 124
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.
 
Old 04-09-2007, 12:18 PM   #11
rickh
Senior Member
 
Registered: May 2004
Location: Albuquerque, NM USA
Distribution: Debian-Lenny/Sid 32/64 Desktop: Generic AMD64-EVGA 680i Laptop: Generic Intel SIS-AC97
Posts: 4,250

Rep: Reputation: 62
Huzza! Huzza! Huzza!
 
Old 04-09-2007, 01:02 PM   #12
zbenjudah
Member
 
Registered: Mar 2006
Posts: 64

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Dutch Master
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
 
Old 04-09-2007, 11:15 PM   #13
nleitao
LQ Newbie
 
Registered: Jun 2006
Location: Aveiro - Portugal
Distribution: Debian
Posts: 8

Rep: Reputation: 0
simple script for installing a list of files

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

good luck

Nuno Leitão

Last edited by nleitao; 04-09-2007 at 11:23 PM.
 
Old 04-11-2007, 02:37 AM   #14
zbenjudah
Member
 
Registered: Mar 2006
Posts: 64

Original Poster
Rep: Reputation: 15
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
 
Old 04-12-2007, 01:09 AM   #15
zbenjudah
Member
 
Registered: Mar 2006
Posts: 64

Original Poster
Rep: Reputation: 15
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"

dpkg -i package1
dpkg -i package2
dpkg -i package3
dpkg -i package4
dpkg -i package5
dpkg -i package6
dpkg -i package7

# 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

Last edited by zbenjudah; 04-12-2007 at 01:25 AM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Script or Simple App to Create HTML Table Populated With Images infidel Linux - Software 14 06-07-2005 01:08 AM
Script to Run the Same Commands on a List of Files Chryzmo Programming 1 10-03-2004 08:34 AM
Simple Script Files jcai Linux - General 4 09-19-2004 07:15 AM
Create custom user's directory with simple script dtournas Programming 2 09-09-2004 05:00 AM
Looking for simple way to create scheduled emails from perl script kdowney Programming 1 10-17-2003 06:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 11:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration