cURL / Mailing Lists / curl-users / Single Mail

curl-users

More whitespace escaping commandline

From: Rasmus Olsen <raol_at_envision.dk>
Date: Thu, 3 Apr 2014 14:09:09 +0000

Hi,

I need a little kick in the right direction. Been fiddling with this whitespace escape problem all day to no avail.

I'm trying to automate FTP uploads of files like this (notice lots of whitspace):

"/Users/gmg/Library/Application Support/Enfocus/Switch Server/backing/DS_DeliverLowres/automanaged/route to#1/_00016_test.pdf"

It works fine when I manually upload this file using curl from the terminal and quote the filepath:

curl -s -f --show-error --ftp-create-dirs -T "/Users/gmg/Library/Application Support/Enfocus/Switch Server/backing/DS_DeliverLowres/automanaged/route to#1/_00016_test.pdf" -u username:password ftp://myserver/subfolder/

But the filepath is not escaped (at least not properly) when calling my script with the same quoted filepath:

gmg$ ./test.sh "filepath with whitespace" username password ftp://myserver/subfolder/

And this is the script:
------------------------------------------------
#!/bin/sh
CMD="curl -s -f --show-error --ftp-create-dirs -T $1 -u $2:$3 $4"
$CMD 2>&1
if [ $? != 0 ]; then {
    echo "Houston we have a problem";
    exit 1;
} fi
echo 0
------------------------------------------------

Can you help out a friend in need :-)

Best wishes,
Rasmus

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2014-04-03