1

I connected to a Windows share using smbclient. In smbclient shell I can't pass an argument (ls -lh)! I can't place a pipe (ls | grep 4547)! I can't even redirect output to a file like in a basic shell (ls > ls.txt)!

How is it supposed to use?! I'm terrified by it's uselessness and futility!

Please give me any examples of smbclient usage that stand for grep'ing things or redirecting output?

2

As I understand smbclient shell does not support grep and io redirection. But you can just mount your samba share to local file system and use all features of bash shell.

You need to install cifs-utils.

$ sudo apt-get install cifs-utils

Now you should be able to mount samba share. Here is example

$ mount.cifs //192.168.1.1/share_point /path_to_your/local/folder -o user,uid=1000,rw,workgroup=DEV,credentials=/path_to_credentials/.cifs

You have to create /path_to_your/local/folder

$ mkdir /mnt/my_share

and credentials file. I suggest to create folder crd in your $HOME, change permission to 700.

$ mkdir ~/crd
$ chmod 700 ~/crd

Now in $HOME/crd create .cifs file with this content:

username=value
password=value
domain=value

Change permission to this file to 600.

$ chmod 600 ~/crd/.cifs

Now you only need to substitute IP address:

$ mount.cifs //192.168.1.1/share_point /mnt/my_share -o user,uid=1000,rw,workgroup=DEV,credentials=$HOME/.cifs

You may also want this mount to be mounted on boot automatically. Add this to your /etc/fstab, at the end

//192.168.1.1/share /mnt/my_share cifs uid=1000,credentials=$HOME/.cifs,iocharset=utf8,sec=ntlm,noauto,user 0 0

Don't forget to substitute $HOME with your home folder, and IP address with appropriate IP.


Sources

  1. mount.cifs man

  2. About smbmount

  3. About fstab and smb mount

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.