Hi I am trying to write an automation script that uses smbclient to run commands on a smb share. Here is the trivial example script and the ouput. Obviously it is breaking the argument on spaces, even though it is quoted. Any help is appreciated.
Code:
#!/sbin/sh
echo "try one"
smbclient -U skunkworx -N -D / //localhost/Shared -c 'ls a'
smb_test ()
{
smbclient -U skunkworx -N -D / //localhost/Shared -c $1
}
echo "try two"
smb_test 'ls a'
echo "try three"
smb_test 'ls'
...and the output :
Code:
$ sh ./smb.sh
try one
Anonymous login successful
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.22-1.fc5]
a D 0 Wed Jul 12 23:41:30 2006
36825 blocks of size 2097152. 28223 blocks available
try two
session setup failed: NT_STATUS_LOGON_FAILURE
try three
Anonymous login successful
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.0.22-1.fc5]
. D 0 Wed Jul 12 22:56:47 2006
.. D 0 Thu Jul 13 00:04:56 2006
a D 0 Wed Jul 12 23:41:30 2006
36825 blocks of size 2097152. 28223 blocks available
As can be seen, try two, when the argument is "ls a", breaks the space giving an error message.