New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
need help with bash script
hey folks
i just started learning how to make my own bash scripts.
now i just need to know how to make a script that detects distribution.
i want to support:
debian
centos 6 + 7
ubuntu any version if possible
does any of you know a place to find a good tuturial?
thanks
perry
Comments
https://unix.stackexchange.com/questions/6345/how-can-i-get-distribution-name-and-version-number-in-a-simple-shell-script
i just want it like this way if possible
No one's going to write the script for you.
@MasonR posted a link that has info on how you can determine the OS and distribution. The top-voted response on that SE link shows you how very easy this is: source /etc/os-release and play with the variables.
What is your question?
is asking for help a crime?
and thanks @masonr
Sure. Please just do some initial investigation next time though and tell us what you've tried and what didn't work. It literally took me all of 10 seconds to google the issue and find that link I posted above.
You're not going to learn bash, as you say, if everything is spoon fed to you. That's what @raindog308 was getting at.
sorry but im trying to learn i have done some research on google/other sites.
how to detect os/distribution
and that what i sended was the only thing i was able to find that what i though i needed.
so said.
sorry then i dont want to make drama here.
edit:
i credited you for the help in my script
Yup.
Nope
Small hint: Try to avoid bash as it is by far not everywhere installed. Instead learn 'sh' scripting. While most OSs/distros have different implementations of what they call 'sh' (e.g. debian -> 'dash') it's a reasonable assumption that 'sh' scripts ("#!/bin/sh") work pretty everywhere (and, if not, require only very minor changes).
You can look at 'sh' as a subset of bash that is available everywhere and the one shell that usually meets the posix requirement for unices.
For googling purposes (e.g. to find tutorials or hints) you can just look for 'dash shell' (which is much easier to google than 'sh'). Moreover, debian should have quite a bit of docu on it.
Second hint: The trick is not simply learning this or that shell but rather to "think unixish" and to know the usual tools and ways.
Example: If adressing all unices or at least not only linux it's common practice to first call "uname -s" which tells you the basic system, i.e. 'Linux' or 'FreeBSD' and then, if linux call 'lsb_release -si', if FreeBSD call 'uname -r' etc.
Ok thank you for the valuable tip