First and foremost, thank you for your guidance in advance!
I am trying to dyamically mount NAS shares (and exclude others) via a BASH script. I would like to browse an open nas share:
#smbclient -L 192.168.1.25 -N Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.24-1.22_OSSTECH] Sharename Type Comment --------- ---- ------- info Disk LinkStation Utilities share Disk LinkStation folder Manager Disk Managers Private Folder IPC$ IPC IPC Service ("Eucalyptus_Share") Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.24-1.22_OSSTECH] Server Comment --------- ------- EUCALYPTUS Eucalyptus_Share Workgroup Master --------- ------- DDDDDOMM DD-D-21075 WORKGROUP EUCALYPTUS
Then grep through the list to remove non-samba-share information and pre-installed information like an "info" share.
Basically, out of all of the text returned, I only want to keep the active shares that I know have data in them. So in this case: share & manager, but for the purpose of expansion, I'd like to code it inversely. I.e. instead searching for share & manager, i want to and identify and exclude everything else, leaving just share & manager. That way, if I later add SCANS, share, manager & scans will now automatically update..
In combination, I currently have a working backup script that executes based on the share name I pass through to it.
I'd VERY much like to create a loop that goes out, grabs the share names, and passes them to the backup script in this format:
./backup.sh share1 share2 ./backup.sh Manager share
What would be the best method to grab the existing shares, filter out details I do not want (Grep? or --exclude?) then have it laid out nicely to echo the share names in a "one-liner"
How can I do this ?