Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
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.
|
 |
05-11-2012, 05:48 PM
|
#1
|
Member
Registered: Feb 2007
Posts: 210
Rep:
|
Create a bash script to automate installation of a program
Hello
Can you help me please to create a bash script script.sh to automate the installation of three programs....
Download-Extract-Install
I want to automate the installation of:
1)skype-ubuntu_2.2.0.35-1_amd64.deb <--- Skype 64Bit
2)FileZilla_3.5.3_x86_64-linux-gnu.tar.bz2 <--- Filezilla
3)reaver-1.4.tar.gz <--- Reaver
I need it for Backtrack based on Ubuntu.
Thank you !!!!
Last edited by ASTRAPI; 05-11-2012 at 05:52 PM.
|
|
|
05-11-2012, 10:28 PM
|
#2
|
Member
Registered: Jul 2009
Posts: 645
Rep:
|
wrong place...
Last edited by cbtshare; 05-12-2012 at 12:59 AM.
|
|
|
05-12-2012, 01:01 AM
|
#3
|
Member
Registered: Jul 2009
Posts: 645
Rep:
|
do you know how to install those programs individually? Thats basically the start of the script.
|
|
|
05-12-2012, 03:54 AM
|
#4
|
LQ Guru
Registered: Sep 2009
Location: Perth
Distribution: Arch
Posts: 10,037
|
As cbtshare said, whatever you would do on the command line, add that into a file with a shebang and make it executable 
|
|
|
05-12-2012, 11:11 AM
|
#5
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852
|
|
|
|
05-12-2012, 09:28 PM
|
#6
|
Member
Registered: Feb 2007
Posts: 210
Original Poster
Rep:
|
Ok thanks one last question
I was try this:
Code:
#!/bin/sh
wget http://reaver-wps.googlecode.com/files/reaver-1.4.tar.gz;
and i get :
Code:
--2012-05-13 03:14:25-- http://reaver-wps.googlecode.com/files/reaver-1.4.tar.gz
Resolving reaver-wps.googlecode.com... 173.194.78.82
Connecting to reaver-wps.googlecode.com|173.194.78.82|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 766603 (749K) [application/x-gzip]
Saving to: `reaver-1.4.tar.gz'
100%[==================================================================================>] 766,603 910K/s in 0.8s
2012-05-13 03:14:26 (910 KB/s) - `reaver-1.4.tar.gz' saved [766603/766603]
: command not found
Why i got that last line : command not found?
Thank you
Last edited by ASTRAPI; 05-12-2012 at 11:16 PM.
|
|
|
05-13-2012, 06:28 AM
|
#7
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852
|
There's nothing in the code snippet you posted that could cause an error like that.
To start with, the ';' at the end of the line acts as a command terminator, although it's unneeded here as a simple newline does the same.
The wget command appears to be working just fine; what's happening is that the shell is seeing something after that as a possible command, and trying to run it... but there's no actual command by that name to run. So there must be something else in the file causing it, either after the semicolon, or on a subsequent line. Perhaps there are even some non-printing characters or something.
So far, the only way I've found to duplicate the error is by adding a quote-protected empty value, such as a variable with nothing in it.
Now for a couple of points of scripting advice for you:
1)
#!/bin/sh is used for interpreting scripts in restricted, posix-compliant lowest-common-denominator mode, and many shell-specific functions may be lost or have their behavior altered. This is mostly recommended for system startup scripts and other cases where portability and standardization are important. When this isn't required, you should use #!/bin/bash (or the path to another shell that has more modern, advanced features available, such as ksh or zsh).
2)
It's usually advisable to separate the code of the script from the data it operates on. Feed the values you want to process into the script from the command line, or store them in a separate file and read that. Or at the very least, set your filenames up at the top of the script in variables first. then use variables in the actual commands later on where the filenames should go. This makes it easier (and safer) to alter the input values without having to go through the whole file making edits.
|
|
|
05-13-2012, 06:55 AM
|
#8
|
Member
Registered: Feb 2007
Posts: 210
Original Poster
Rep:
|
Great thanks 
|
|
|
All times are GMT -5. The time now is 02:53 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
|
|