Reputation: 1305
I have written a Shell script that moves into a directory with some binaries files present.
What I am looking to do is transfer all the files present inside this directory.
cd /home/user/binaries
smbclient //ip.address/directory$ password -W domain -U username << ENDOFMYSMBCOMMANDS
prompt
put *
exit
ENDOFMYSMBCOMMANDS
I tried to use put *
to transfer all files - but this is not accepted.
The only other option I know of is to go one folder up, and use the command mput binaries
- but this copies everything including the folder.
How can I modify my script to only transfer the contents of the directory?
Upvotes: 1
Views: 6870
Reputation: 3749
I'm going to format the self-answer of Dustin a bit differently into a real one-liner. It is also possible to add the prepended "cd" command into the smbclient command, like so:
smbclient //ip.address/directory -W domain -U username \
-c 'prompt OFF; recurse ON; cd remote/target/directory; lcd /local/source/directory; mput *'
Upvotes: 3
Reputation: 1305
I had the answer with me all along!! I was under the impression that mput
could only be used to transfer a directory, turns out that using mput *
inside a directory will copy all the files located within that directory!
cd /home/user/binaries
smbclient //ip.address/directory$ password -W domain -U username << ENDOFMYSMBCOMMANDS
prompt
put *
exit
ENDOFMYSMBCOMMANDS
Going to leave this here for anyone else who gets stumped on this like me!
Upvotes: 1