The following code runs into error:
for i in {190..208}; do curl -k -F 'act=upload' -F 'apk=@apks/apk_${i}.apk' -F 'comment=md5: `md5 apks/apk_$i.apk`' https://username:password@myhost.com/; done
The server has an self-signed cert, so, I tried to turn off the ssl with -k.
reponse:
curl: (26) SSL: unable to obtain common name from peer certificate
curl: (26) SSL: unable to obtain common name from peer certificate
curl: (26) SSL: unable to obtain common name from peer certificate
......
curl: (26) SSL: unable to obtain common name from peer certificate
But, if I change my command to:
for i in {190..208}; do echo "curl -k -F 'act=upload' -F 'apk=@apks/apk_${i}.apk' -F 'comment=md5: `md5 apks/apk_$i.apk`' https://username:password@myhost.com/" >> tmp.sh; done
bash tmp.sh
It works without any warning.
I have no idea why.
Thank you.
P.S.
Some info.
logan $ uname -a
Darwin Logans-MacBook.local 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386
logan $ /usr/bin/curl --version
curl 7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l zlib/1.2.3
Protocols: tftp ftp telnet dict ldap http file https ftps
Features: GSS-Negotiate IPv6 Largefile NTLM SSL libz
Others have mentioned using “” instead of ” to correctly expand the ${i} variable.
However, this shouldn’t have an effect on curl’s SSL checking. To answer your general question about “why does bash behave differently with A and B”, try comparing the output seen with
set -x. This shows exactly what is being executed by the shell, after variable substitution and quote processing. A short example:If you compare bash’s output with the “+”-prefixed lines, you should spot how the shell is interpreting the line in both command-line and tmp.sh.