LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sending SMB Client Commands Through Shell Script (https://www.linuxquestions.org/questions/linux-newbie-8/sending-smb-client-commands-through-shell-script-4175535032/)

Dustin Cook 02-25-2015 02:02 AM

Sending SMB Client Commands Through Shell Script
 
Hello.

I have a shell script, which I am using to access the SMB Client:

Code:

#!/bin/bash
cd /home/username
smbclient //link/to/server$ password -W domain -U username
recurse
prompt
mput baclupfiles
exit

Right now, the script runs, accesses the server, and then asks for a manual input of the commands.

Can someone show me how to get the commands:
Code:

recurse, prompt, mput baclupfiles and exit
to be run by the shell script please?

linosaurusroot 02-25-2015 04:01 AM

Do you want those commands run by smbclient? If so a "here document" should do it.

Code:

#!/bin/bash
cd /home/username
smbclient //link/to/server$ password -W domain -U username << ENDOFMYSMBCOMMANDS
recurse
prompt
mput baclupfiles
exit
ENDOFMYSMBCOMMANDS


Dustin Cook 02-25-2015 04:18 AM

Thanks linosaurusroot! That solved my problem!

It's a nice neat solution too - I like it :)


All times are GMT -5. The time now is 07:30 PM.