Reputation: 1
how can i use single quote in smbclient "put" command?
For example:
smbclient -c 'put "/mydir/video.avi" "\Music\Guns N' Roses\video.avi"'
The ' in "Guns N' Roses" generate an error, but i cannot use "Guns N\' Roses", because will change path.
Upvotes: 0
Views: 1291
Reputation: 46826
Your shell doesn't allow use of escaped single quotes inside a single-quoted string. Read the section entitled "QUOTING" in man bash
(assuming your shell is bash).
You need to escape the inner single quotes outside the single-quoted string:
smbclient -c 'put "/mydir/video.avi" "\Music\Guns N'\'' Roses\video.avi"'
Or, if you prefer:
smbclient -c 'put "/mydir/video.avi" "\Music\Guns N'"'"' Roses\video.avi"'
Or alternately, you could put things in variables, use formatting, etc. Obviously I haven't tested this in your environment, but the following seems reasonable to me:
$ source="/mydir/video.avi"
$ target="\Music\Guns N' Roses\video.avi"
$ cmd='put "$s" "$s"'
$ smbclient -c "$(printf "$cmd" "$source" "$target")"
Upvotes: 0