ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You don't need echo or any command substitution; if you need to store the output of pwd, you should use:
location=$(pwd)
However, you don't even need that, as the current directory is stored in $PWD:
location=$PWD
Quote:
Code:
while [ "$quit" = "n" ];
do
clear
echo "Secondary Node Control Utility"
echo
echo
echo "1. Activate Heartbeat and Failover System"
echo "Q. Quit"
echo
echo "Enter choice:"
read choice
case $choice in
1) while [ "$BEAT" -eq 0 ];
do
dump=`ping -c 1 192.168.225.120`
if [ ! $? == 0 ];
then
echo "WARNING: Primary Node is Dead"
let BEAT=BEAT+1
I recommend using the portable, POSIX syntax for shell arithmetic:
BEAT=$(( $BEAT + 1 ))
Quote:
Code:
else
echo "Primary Node is Alive at:"
fi
done
You are missing the closing ';;' before the next case.
hey sorry bother folk again but im tryin to make a bigger menu system on another similar script is it possible to have a case with a another, my attempts so far have failed
Code:
#!/bin/sh
#Filename: nascontrol
quit=n
location=$(echo $(pwd))
while [ "$quit" = "n" ]
do
clear
echo "Network Attached Storage Control Utility"
echo
echo "Your current location is: " $location
echo
echo "1. NFS Mount Space"
echo "2. NFS Unount Space"
echo "3. Check NFS Service Status"
echo "4. Start NFS Service"
echo "5. View Currently Exported Areas"
echo "6. View Available Directories"
echo "Q. Quit"
echo
echo "Enter choice:"
read choice
case $choice in
1) echo "Please enter the directory you would like to export:"
echo
echo "Would you like include the current working directory?"
read pwdquest
case $pwdquest in
Y|y) echo "Enter Directory under: $location"
read sharedir
echo
exportfs -v :$location/$sharedir
echo "Directory has been Exported"
echo
echo "Hit Enter..."
read junk;;
N|n) echo "Enter full path of directory"
read shareddir
echo
exportfs -v :$sharedir
echo "Directory has been Exported"
echo
echo "Hit Enter..."
read junk;;
*) echo "Invalid choice!"
sleep 1
esac
done ;;
2) echo "Please enter the directory you would like to unexport"
read unsharedir
exportfs -u :$unsharedir
echo "Directory is no longer being exported"
echo
echo "Hit Enter..."
read junk;;
3) service nfs status
echo "Hit Enter..."
read junk;;
4) service nfs start
echo "Hit Enter..."
read junk;;
5) showmount -e
echo
echo "Hit Enter..."
read junk;;
6) dir
echo
echo "Hit Enter..."
read junk;;
Q|q) quit=y;;
*) echo "Invalid choice!\07\07"
sleep 1
esac
done
echo "Program Exit Completed"
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789
Rep:
There was one "do" but two "done" in your script ...
Edited: Ygloo, please add some comments to your postings. An empty post or one with only code doesn't help figuring out where you are now with your script.
hey sorry bother folk again but im tryin to make a bigger menu system on another similar script is it possible to have a case with a another, my attempts so far have failed
$ time location=$PWD
real 0m0.000s
user 0m0.000s
sys 0m0.000s
$ time location=$( echo $(pwd))
real 0m0.010s
user 0m0.001s
sys 0m0.008s
Quote:
Code:
while [ "$quit" = "n" ]
do
clear
echo "Network Attached Storage Control Utility"
echo
echo "Your current location is: " $location
echo
echo "1. NFS Mount Space"
echo "2. NFS Unount Space"
echo "3. Check NFS Service Status"
echo "4. Start NFS Service"
echo "5. View Currently Exported Areas"
echo "6. View Available Directories"
echo "Q. Quit"
echo
echo "Enter choice:"
read choice
case $choice in
1) echo "Please enter the directory you would like to export:"
echo
echo "Would you like include the current working directory?"
read pwdquest
case $pwdquest in
Y|y) echo "Enter Directory under: $location"
read sharedir
echo
exportfs -v :$location/$sharedir
echo "Directory has been Exported"
echo
echo "Hit Enter..."
read junk;;
N|n) echo "Enter full path of directory"
read shareddir
echo
exportfs -v :$sharedir
echo "Directory has been Exported"
echo
echo "Hit Enter..."
read junk;;
*) echo "Invalid choice!"
sleep 1
esac
done ;;
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.