Create a bash script to automate installation of a program
Linux - NewbieThis 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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.