LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 05-11-2012, 05:48 PM   #1
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Rep: Reputation: 16
Question 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.
 
Old 05-11-2012, 10:28 PM   #2
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
wrong place...

Last edited by cbtshare; 05-12-2012 at 12:59 AM.
 
Old 05-12-2012, 01:01 AM   #3
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
do you know how to install those programs individually? Thats basically the start of the script.
 
Old 05-12-2012, 03:54 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,976

Rep: Reputation: 3181Reputation: 3181Reputation: 3181Reputation: 3181Reputation: 3181Reputation: 3181Reputation: 3181Reputation: 3181Reputation: 3181Reputation: 3181Reputation: 3181
As cbtshare said, whatever you would do on the command line, add that into a file with a shebang and make it executable
 
Old 05-12-2012, 11:11 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Get your hands dirty then and start studying scripting. There are a lot of good resources available for you to learn from.

Here are a few useful bash scripting references:
http://mywiki.wooledge.org/BashGuide
http://www.linuxcommand.org/index.php
http://mywiki.wooledge.org/BashFAQ
http://mywiki.wooledge.org/BashPitfalls
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/index.html
http://www.gnu.org/software/bash/manual/bashref.html
http://wiki.bash-hackers.org/start
http://ss64.com/bash/

The first link in particular covers all the basic concepts you need to know.
Good luck!
 
Old 05-12-2012, 09:28 PM   #6
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Original Poster
Rep: Reputation: 16
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.
 
Old 05-13-2012, 06:28 AM   #7
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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.
 
Old 05-13-2012, 06:55 AM   #8
ASTRAPI
Member
 
Registered: Feb 2007
Posts: 210

Original Poster
Rep: Reputation: 16
Great thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] Bash script to Automate the Virtual Host creation process!! anishkumarv Linux - Newbie 3 03-14-2011 10:03 PM
how to automate an installation script suppressing user interaction aditi Programming 2 02-08-2010 11:43 PM
how to automate an installation script suppressing user interaction aditi Linux - Newbie 1 02-06-2010 05:56 AM
How to program shell script to automate mass user account creation? EsAsher Linux - General 2 06-30-2007 08:41 AM
Automate Samba logon with a bash script? achtung_linux Linux - Networking 6 10-22-2006 02:36 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:30 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