I'm pretty new to Ubuntu linux, let's say all of linux because I installed it a few days ago. I'm sorry for my mistakes in my use of English, because I live in the Netherlands.
Well I tried to do some programming, writing a script, but I encountered a problem which I haven't been able to solve yet. Well I was writing a script, and I want this script to automatically install a few things for me. Well I was doing and tried to make as less nests as I could, and I finished my script, but I thought. Why wouldn't I try to put a few lines in it which check if the programs are correctly installed. So I wondered how I could do it and I came up with the following:
Because I'm new to programming I wanted it to be so advanced as I could by myself. So I decided to try to work with shell functions. These functions check if the correct file is there, and the outcome of these functions has to be a value which I can use later. Here an example:
function isitthere
{
if [ -f <thefile> ]; then
true
else
false
fi
}
if [ $(isitthere) = "true" ]; then
echo "Your program is properly installed"
else
echo "Your program isn't properly installed.
fi
In this example are true and false my values, and as you see, I try to re-use them in my second command. I know this can be done much more easily, but I want to know if it is possible, and if it is possible how. Because in one part of my script doing it like this makes it much easier. Is there any way you can give a value to your if command and use that value later in your next if command? Thanks.