Simon336697
asked on
Creating a Bash Script Menu
Hi guys!
Id love some help in trying to build a bash script menu.
What Im trying to do is the following...
1. Run a bash script eg.menu.sh
2. When run, it presents the following information......
========================== =====
--------- BASH MENU: Menu.sh ---------
========================== =====
Execute the following commands by typing the correct number...
[1] Connect to fire's temp folder
[2] Connect to fire's backup folder
[3] Switch to fire's temp folder
[4} Switch to fire's backup folder
[5] Disconnect from fire's backup folder
[6] Disconnect from fire's temp folder
-------------------------- ---------- ---------- ---------- ---------- ---------- ---------- ---
3. The user types '1' to connect ot fire's temp folder for example.
4. The commands I have for this are:
-------------------------- ---------- ----------
[1] Connect to fire's temp folder
mount -t cifs //192.168.2.3/fire_temp /mnt/net_temp_h_fire_fire_ temp -v -o user=scripter,pass=passwor d,domain=W ORKGROUP,r w'
-------------------------- ---------- ----------
[2] Connect to fire's backup folder
'mount -t cifs //192.168.2.3/fire_backups /mnt/net_backups_h_fire_fi re_backups -v -o user=scripter,pass=passwor d,domain=W ORKGROUP,r w'
-------------------------- ---------- ----------
[3] Switch to fire's temp folder
cd /mnt/net_temp_h_fire_fire_ temp; clear; echo "===== h:\fire\fire_temp ====="; pwd; ls -ltra | more'
-------------------------- ---------- ----------
[4} Switch to fire's backup folder
cd /mnt/net_backups_h_fire_fi re_backups ; clear; echo "===== h:\fire\fire_backups ====="; pwd; ls -ltra | more'
-------------------------- ---------- ----------
[5] Disconnect from fire's backup folder
umount /mnt/net_backups_h_fire_fi re_backups
-------------------------- ---------- ----------
[6] Disconnect from fire's temp folder
umount /mnt/net_temp_h_fire_fire_ temp
================
I will add more above, but i just want to get the general idea how you would build this menu.sh script, so that a menu is presented, and all you have to do is press a number for the option you want to be executed.
Any ideas greatly appreciated.
Id love some help in trying to build a bash script menu.
What Im trying to do is the following...
1. Run a bash script eg.menu.sh
2. When run, it presents the following information......
==========================
--------- BASH MENU: Menu.sh ---------
==========================
Execute the following commands by typing the correct number...
[1] Connect to fire's temp folder
[2] Connect to fire's backup folder
[3] Switch to fire's temp folder
[4} Switch to fire's backup folder
[5] Disconnect from fire's backup folder
[6] Disconnect from fire's temp folder
--------------------------
3. The user types '1' to connect ot fire's temp folder for example.
4. The commands I have for this are:
--------------------------
[1] Connect to fire's temp folder
mount -t cifs //192.168.2.3/fire_temp /mnt/net_temp_h_fire_fire_
--------------------------
[2] Connect to fire's backup folder
'mount -t cifs //192.168.2.3/fire_backups
--------------------------
[3] Switch to fire's temp folder
cd /mnt/net_temp_h_fire_fire_
--------------------------
[4} Switch to fire's backup folder
cd /mnt/net_backups_h_fire_fi
--------------------------
[5] Disconnect from fire's backup folder
umount /mnt/net_backups_h_fire_fi
--------------------------
[6] Disconnect from fire's temp folder
umount /mnt/net_temp_h_fire_fire_
================
I will add more above, but i just want to get the general idea how you would build this menu.sh script, so that a menu is presented, and all you have to do is press a number for the option you want to be executed.
Any ideas greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You guys are INCREDIBLE and INCREDIBLY HELPFUL AND KIND!!!
I will test and report back to both of you :>)
I will test and report back to both of you :>)
ASKER
They are both brilliant!
Guys I cant thank you enough.
Guys they work great. Can I just finish off by asking you both...
In the case example, what does the
esac
at the end of the case actually do?
What does the
until [ "1" = "0" ]; do
until 1 actually do?
You guys are great.
Guys I cant thank you enough.
Guys they work great. Can I just finish off by asking you both...
In the case example, what does the
esac
at the end of the case actually do?
What does the
until [ "1" = "0" ]; do
until 1 actually do?
You guys are great.
The until loop basically just loops forever, it will loop until 1 = 0 which will never happen.
In the case, esac marks the end of the case statement (the } at the end it a bit miss leading you may be mistaken for thinking that was the end of the case but it is the end of the function), so esac just says there are no more cases to be defined for that construct.
mcuk_storm
In the case, esac marks the end of the case statement (the } at the end it a bit miss leading you may be mistaken for thinking that was the end of the case but it is the end of the function), so esac just says there are no more cases to be defined for that construct.
mcuk_storm
ASKER
mcuk_storm!
Mate thanks so much that explains it thanks again :>)
Mate thanks so much that explains it thanks again :>)
Kind Regards,
mcuk_storm
Open in new window