Well there are a number of issues, the first being, please use [ code ] [/ code ] tags (without the spaces) so we can read your code.
As for the code:
Quote:
./d.sh: line 5: r: command not found
|
This error is because shell scripting is a top down language, meaning that up until line 5 the function r has yet to be defined
Second problem, if you are going to use global variable, ie the variable 'n', why bother having separate functions?
Choices are to amalgamate the entire script and define n only once or use the reserved word local to create them so they only exist within each function.
Part two of the second choice is to the call the functions correctly, ie with the passed in values not the global ones. This mean that your r function
would become something like:
Code:
function r{
ifconfig eth$1
}
[quote]eth2: error fetching interface information: Device not found[/code]
This error is not related to your code but rather that you have no such device called eth2