smbclient in bash with spaces in share path

Zev Spitz shivisi at nana.co.il
Wed Jun 6 14:06:18 GMT 2007


Hello all,
I am new to Linux and Samba.
I am trying to write a script to put received faxes from a FC6 computer
to a WinXP share. Bash seems to build the command properly, as is
reported by the smbclient error, but although the command works from the
command-line, it doesn't work when passed together with smbclient.
I don't know if this is something with smbclient, or with bash.

--- Script:
#!/bin/bash
i='/home/zevi/My.planner'
FILENAME=`basename $i`
COMMAND="put $i "\""common\\Incoming faxes\\testsh\\$FILENAME.txt"\"
"smbclient //windows2/shareddocs -N -c '$COMMAND'"

--- Output:
test6.sh: line 5: smbclient //windows2/shareddocs -N -c 'put
/home/zevi/My.planner "common\Incoming faxes\testsh\My.planner.txt"': No
such file or directory

--- Trace+Output:
+ i=/home/zevi/My.planner
++ basename /home/zevi/My.planner
+ FILENAME=My.planner
+ COMMAND='put /home/zevi/My.planner "common\Incoming
faxes\testsh\My.planner.txt"'
+ 'smbclient //windows2/shareddocs -N -c '\''put /home/zevi/My.planner
"common\Incoming faxes\testsh\My.planner.txt"'\'''
test6.sh: line 5: smbclient //windows2/shareddocs -N -c 'put
/home/zevi/My.planner "common\Incoming faxes\testsh\My.planner.txt"': No
such file or directory

--- Note:
The following command works fine, when typed into the command line:
smbclient //windows2/shareddocs -N -c 'put /home/zevi/My.planner
"common\Incoming faxes\testsh\My.planner.txt"'



More information about the smb-clients mailing list