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 made a script for mounting but what how would I post that it has mounted sucessfully in the script. I want to echo "Mounted all sucessfully" and "One or more didn't not mount sucessfully. It's pulls from my fstab. Any help would be great! Thanks!
Generally difficult to assist without seeing the code as you may have loops and or read statements to deal with that could cause output to not display.
Indeed, better to see what you've tried so far. Anyway, using a loop you may want something like this:
Code:
while read device mount_point
do
mount $device $mount_point || NO_MOUNT=1
done < list_of_devices_and_mount_points
[[ -z $NO_MOUNT ]] && echo Mounted all successfully || echo One or more didn't mount successfully
It's a small script but obviously to do all the mounting it needs to be in root. After mount -a, if it successfully mounts without an error I want to echo "Mounted Sucessfully" if didn't mount all, I want it to echo "One or more have not sucessfully mounted". Thank you in advance for your help.
Last edited by poseidonsurf; 02-28-2013 at 10:08 PM.
Reason: Expanded.
it is *REALLY* bad idea to use expect like that to provide the root password.
Anyway as we've already mentioned mount will exit with 0 status if there were no problems, and non zero otherwise. We have also already provided example code for this.
Thank you everyone for you quick replies. Evo2 - I thought I needed root to mount all drives? Maybe not. I will see. Is there a way to put a count down before the screen exits?
I thought I needed root to mount all drives? Maybe not. I will see.
You don't need root to mount drives that have the flag "user" in /etc/fstab. Also any drive that does not have the "noauto" flag will be mounted automatically at boot (and whenever "mount -a" is run. Have a look at the mount and fstab man pages.
Quote:
Is there a way to put a count down before the screen exits?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.