• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 326
  • Last Modified:

Need a script to check for a mount then mount share if not found

I need a script to check if a share is mounted. Lets call the server ABC and the share 123. I need a script to see if the share is mounted and if it is then call another script. If it is not mounted then the script should check to see if /mnt has a share mounted to it. If not then mount the share to /mnt. If /mnt is already used then check /tmp and mount to /tmp. If both /mnt and /tmp are already being used then exit and do nothing. Once the share is mounted then call another script.
0
SpyderGST1
Asked:
SpyderGST1
  • 3
  • 2
1 Solution
 
ahoffmannCommented:
why reinwenting the wheel? use automounter

Anyway:
(cd /mnt/ABC/123 2>&1) && /path/to/another/script || (mount /mnt/ABC/123 && /path/to/another/script)

# assumes that you have setup /etc/fstab proper
0
 
SpyderGST1Author Commented:
Thanks you.
Because I need to put this on several servers across the US and I don't admin these servers. I need this mount for my app. I can suggest it to the Unix team.
Thanks
0
 
ahoffmannCommented:
ok, if you don't admin these servers someone need to configure them for your mounts
then my suggestion should work (well you may write a script of your choice using the proper if--then--else syntax, which willmake it more portable)
0
 
SpyderGST1Author Commented:
Actually the if, then statements is what I was looking for since I do need it to be more portable.
0
 
ahoffmannCommented:
#!/bin/sh
cd /mnt/ABC/123 2>&1
if [ $? -ne 0 ]; then
  mount /mnt/ABC/123 || exit 42
fi
/path/to/another/script
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now