Take activity if remote web server replies to ping
I have actually a network affixed storage (NAS) in the house where I store virtually all my media things (tracks, video clips, etc). I would love to place it to a neighborhood directory site in my note pad instantly every single time I login in the house so prior to placing it I require to do a ping to see if it is addressing (which suggests I'm residence).
I currently have the manuscript to place it (see listed below) yet I have 2 inquiries :
1) How to make use of the solution from ping in order to see if its answering? I think I need to make use of grep along with the ping command, yet given that I'm a new *nix customer I'm not really well-versed with it yet.
2) Where is the most effective area to place this manuscript?
The place command I have is this :
sudo mount -t cifs //myIpAddress/remoteDir /media/MyLibrary -o username=myUsername,password=myPassword,domain=myDomain,iocharset=utf8,file_mode=0777,dir_mode=0777
No demand for grep or anything like that, simply do this :
ping -c 4 foo && sudo mount ...
This primarily makes use of the reality that ping returns real if the ping functions, the - c restricts it to 4 pings prior to returning. You can additionally do something if ping falls short similar to this :
ping -c 4 foo || echo "FAILED!"
The various other point to take into consideration is why you are placing on login and also not in your fstab, there are some excellent overviews to placing smb documents storage space online :