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.
I have some experence coding in C++, Java but that was a HS class a few years ago, but we never did any work with external files so thats where I need help
Code:
#!/bin/bash
declare var ISO
function main
{
echo "Welcome to ISO tools"
echo ""
echo "1) Mount an Image"
echo "2) Unmount Image"
echo "3) Quit"
read var
if [ $var -eq "1" ]
then
clear
umount /mnt/iso #I got some wierd message about it being mounted multiple times so I added this
echo "Select an ISO to mount"
#need to display the all the ISO locations and have them numbered so the number can be selected
read ISO
if [ $ISO -eq "0" ]
then
echo "enter the new ISO's path"
read ISO
echo $ISO >> iso.dat
while [ $ISO -eq $var ]
do
# $ISO needs to be redefined as with its coorisponding location
done
fi
mount -t iso9660 -o loop $ISO /mnt/iso
elif [ $var -eq "2" ]
then
umount /mnt/iso
elif [ $var -eq "3" ]
then
exit
else
clear
main
fi
}
clear
main
exit
the select command will print numbered choices for you automatically.
Endlessly until you break
And you can use case which looks a bit neater than nested if statements
and uses globbing.
something like:
Code:
select file in QUIT *.iso ;do
case $file in
QUIT) break 2
;;
*) mount $file
esac
# break
done
but I was hoping that I wouldn't have to hardcode all the iso locations, I was hoping to access them from a .dat so when I wanted to add a new ISO location I didn't have to modify the source code.
The wide tab stops & esp. the long comment lines keep people from easily reading & grasping your code. Especially you, if you come back to it in, say, 6 months time. As a side effect it hoses the display of the entire thread on Konqueror -- it forces horizontal scrolling == PITA.
If you have any doubt about the idea of your future self as one of your most important readers, track down & read ESR's (Eric Raymond) piece on why he likes Python better than Perl.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.