I have the following script:
#!/bin/sh BACKUP=/respaldoBD NOW=$(date +"%d_%m_%Y") SMBCLIENT="$(which smbclient)" DBS="zabbix" for db in $DBS do FILE="mysql_$db.$NOW.gz" echo $FILE PARM="prompt; recurse; mput $FILE; exit;" for f in $FILE do $SMBCLIENT //192.168.3.57/publica -A $BACKUP/.smbclient -c "\""$PARM"\$ done done
When i execute the script, i only get "Domain=[SEGCAT] OS=[Windows 8.1 Pro 9600] Server=[Windows 8.1 Pro 6.3]" and the file doesn't get copied.
If i echo the $smbclient line, and copy and paste it directly, it copies the file perfectly. I don't know what's happening, it doesn't make sense to me.
EDIT: the fix was to replace the $SMBCLIENT line with: $SMBCLIENT //192.168.3.57/publica -A $BACKUP/.smbclient -c "prompt; recurse; mput $FILE; exit;"