Trying to do a script to download a file using wget, or curl if wget doesn't exist in Linux. How do I have the script check for existence of wget?
相关问题
- How to get the return code of a shell script in lu
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Invoking Mirth Connect CLI with Powershell script
- Error building gcc 4.8.3 from source: libstdc++.so
First thing to do is try install to install
wget
with your usual package management system,. It should tell you if already installed;Otherwise just launch a command like below
If you receive no error, then its ok.
One can also use
command
ortype
orhash
to check if wget/curl exists or not. Another thread here - "Check if a program exists from a Bash script" answers very nicely what to use in a bash script to check if a program exists.I would do this -
Linux has a
which
command which will check for the existence of an executable on your path:As you can see, it sets the return code
$?
to easily tell if the executable was found.