LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   How do I check if smbfs is accessible from Win Clients using a linux script (https://www.linuxquestions.org/questions/linux-server-73/how-do-i-check-if-smbfs-is-accessible-from-win-clients-using-a-linux-script-472459/)

townlevel 08-09-2006 07:22 PM

How do I check if smbfs is accessible from Win Clients using a linux script
 
I am trying to write a PHP script (hosted on linux/apache/smb server) to automatically check if //NETBIOSNAME/SHARE (a samba smbfs share) is definitely accessible to windows clients before writing stuff to the unix mount point for the said share.

If I just check the linux mountpoint (e.g. /win_mounts/sharename) exists that doesn't tell me that //NETBIOSNAME/SHARE is still mounted to it.

Nor will PHP let me check using for example is_writable('//NETBIOSNAME/SHARE') from a linux hosted apache web server, it only lets me check the linux file system (i.e. the mount point, not if it's actually mounted).

smbclient I hear you cry, however smbclient always takes you to a smbclient /> command prompt and I have been unable to find any way to
bypass this 'smbclient />' command prompt, which requires human input to execute smbclient commands and cannot it seems be executed by passing a line of code and options to it.

Does anyone have any suggestions on either how to supress the command prompt interface of smbclient so it returns results from single line requests, or have some other ideas on how to test if a windows share is mounted on the unix/linux file system and will be visible to windows clients ?

I welcome your thoughts

Many thanks

scheidel21 08-10-2006 08:59 PM

Been a while since I used smbclient, however, i believe you can specify all the information in the command line i.e. <Quote>smbclient -u scheidel -p 5555555 //WINS_Name/ShareName/</Quote>

Alex

archtoad6 09-05-2006 06:44 PM

From man smbclient
Quote:

-c command string
command string is a semicolon-separated list of commands to be executed instead of prompting from stdin. -N is implied by -c.

townlevel 09-06-2006 11:43 PM

Voila - it works
 
My problem is now solved.

Many thanks archtoad.

Both the -c and also the discovery that commands would only work when enclosed in quotes has finally got this working as I wanted.

For ages I'd either not used quotes or put them in the wrong place, enclosing each command for example, but this example finally works:

smbclient //COMPNAME/SHARENAME -U win_user%win_pass -c 'cd subdir;put file.txt;ls ./;'

I take back everything I said about smbclient being a worthless a piece of sh**

Many thanks for your replies.

nick1 09-28-2006 02:51 PM

THANK YOU SO MUCH for posting your example! Those darn '' were driving me nuts!

*Nick*


All times are GMT -5. The time now is 01:06 PM.