How to delete a file with '&' in its name on SFTP
Date: Fri, 3 May 2019 10:03:30 +1200
Hi,
We have a curl process that downloads files from an SFTP site and then
removes the downloaded file from the SFTP source. It works fine for
'normal' filenames so syntactically there's nothing wrong with the command
we use:
C:\Progra~1\RipCurl\cURL\curl.exe -f --connect-timeout 10 --retry 1
--retry-delay 30 -s -S -k -u "<uname>:<pword>" "sftp://<sftp
site>/transfer/Waikato/blah.txt" -o "E:\<...>\Waikato\Download\blah.txt" -Q
"-rm """/transfer/Waikato/blah.txt"" -w "%{size_download} bytes,
%{time_total} ms"
However when the file to be deleted contains an ampersand (&) the command
fails with the following error:
*curl: (21) Syntax error: Bad first parameter*
Attempt to resolve it that don't work:
1) Using the {} option
C:\Users\Administrator>C:\Progra~1\RipCurl\cURL\curl.exe -f
--connect-timeout 10 --retry 1 --retry-delay 30 -s -S -k -u "
<uname>:<pword> " "sftp://<sftp site>/transfer/Waikato/{Alw&Ded.txt}" -Q
"rm /transfer/Waikato/#1"
The SFTP response is now a better one but still not allowing the file to be
deleted:
curl: (21) rm command failed: No such file or directory
Even with additional double-quotes for the quote command (-Q "-rm
\"/transfer/Waikato/#1\"") the (21) SFTP response is still generated.
2) Replace & with %26 or \x26 - doesn't work.
We use curl version 7.23.1.
How can a file with '&' in its name be deleted on SFTP?
Thank you,
Martijn
-- The information contained in this e-mail message and any accompanying files is or may be confidential. If you are not the intended recipient, any use, dissemination, reliance, forwarding, printing or copying of this e-mail or any attached files is unauthorised. This e-mail is subject to copyright. No part of it should be reproduced, adapted or communicated without the written consent of the copyright owner. If you have received this e-mail in error please advise the sender immediately by return e-mail or telephone and delete all copies. Nine Group does not guarantee the accuracy or completeness of any information contained in this e-mail or attached files. Internet communications are not secure, therefore Nine Group does not accept legal responsibility for the contents of this message or attached files.
-----------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-users
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2019-05-03