straygrey Posted March 2, 2011 Share Posted March 2, 2011 Is there a way for me to connect to a directory on a NAS server running a windows share from PHP. I can connect from the command line using mount, but I want the connect within my PHP script. Can this be done & if so how? Quote Link to comment https://forums.phpfreaks.com/topic/229354-connect-to-a-directory-on-a-nas-server/ Share on other sites More sharing options...
trq Posted March 2, 2011 Share Posted March 2, 2011 You don't connect to shares. Mount it, then access it. What exactly do you want to do with it from php? Quote Link to comment https://forums.phpfreaks.com/topic/229354-connect-to-a-directory-on-a-nas-server/#findComment-1181744 Share on other sites More sharing options...
straygrey Posted March 2, 2011 Author Share Posted March 2, 2011 We need to check that todays backup file exists & if not email responsible person. Quote Link to comment https://forums.phpfreaks.com/topic/229354-connect-to-a-directory-on-a-nas-server/#findComment-1181748 Share on other sites More sharing options...
trq Posted March 2, 2011 Share Posted March 2, 2011 Just mount it via exec. Quote Link to comment https://forums.phpfreaks.com/topic/229354-connect-to-a-directory-on-a-nas-server/#findComment-1181761 Share on other sites More sharing options...
gizmola Posted March 2, 2011 Share Posted March 2, 2011 This is the type of thing where it would probably just be better to do this in a bash script, if the idea is that you want to mount the shared drive, test for the existence of a file, email if it's not there, and then unmount it. Quote Link to comment https://forums.phpfreaks.com/topic/229354-connect-to-a-directory-on-a-nas-server/#findComment-1181765 Share on other sites More sharing options...
straygrey Posted March 2, 2011 Author Share Posted March 2, 2011 That is exactly what I want to do, gizmola. Quote Link to comment https://forums.phpfreaks.com/topic/229354-connect-to-a-directory-on-a-nas-server/#findComment-1181768 Share on other sites More sharing options...
gizmola Posted March 2, 2011 Share Posted March 2, 2011 Well there's mount and umount, which you should be able to test from the shell. Add those to your script, and you can test for the existence of a file with: #!/bin/bash #mount share here if [ ! -f /mountdir/backupfilename ] then mail -s "Backup file missing" [email protected] fi #umount here That's about all there is to it. Stick in a cron for this at the appropriate time, and you should be covered. Quote Link to comment https://forums.phpfreaks.com/topic/229354-connect-to-a-directory-on-a-nas-server/#findComment-1181770 Share on other sites More sharing options...
straygrey Posted March 2, 2011 Author Share Posted March 2, 2011 Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/229354-connect-to-a-directory-on-a-nas-server/#findComment-1181780 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.