maybe I didnt write correctly and you missunderstood me, i'm sorry.
what i want to do is. when i open my script my normal menu appers. now i just want to make it quicker and enter the function after the test.sh path i already defined before and get my data.
greets
Hi,
your script defines some functions but never uses them. When you process the userinput you call some commands directly that you use in the functions .
About your problem: command line arguments are stored in the positional parameters. They are referenced by a number which reflects their position. The first argument is $1 , the second $2 ,... The special parameter $# holds the number of arguments passed.
I would check if $# is 1 and if that's true assign the corresponding number to the variable input depending on what $1 holds.
#!/bin/sh
#
# Vars & Functions
#
MENU="memory space ip user"
memory () {
free -m
}
space () {
df -h
}
ip () {
arp
}
user () {
whoami
}
#
# Menu
#
if [[ -z $1 ]]
then echo "Select which info to display"
select ENTRY in $MENU;do break;done
else ENTRY=$1
fi
#
# Execute
#
$ENTRY
Hope this helps
NOTE:
This only works as long as the menu entry to choose from is named identical as the function to execute