28

I am working on a simple bash script to download images from the website Tumblr. The idea is to use read to get login info from the user, and wget --post-data to log in, and this is what I have:

read -p "Tumblr login email: " EMAIL
read -p "Tumblr login password: " PASSWRD
wget --user-agent=Mozilla/5.0 --save-cookies cookies.txt --post-data 'email=$EMAIL&password=$PASSWRD' --no-check-certificate https://www.tumblr.com/login

However, it is sending "$EMAIL" and "$PASSWRD" instead of the strings for the variables, is there any way to get it to send values that have been inputted by the user?

4

2 に答える 2

63

変化する:

--post-data 'email=$EMAIL&password=$PASSWRD'

に:

--post-data="email=$EMAIL&password=$PASSWRD"

bash マニュアルについてQuoting: http://www.gnu.org/software/bash/manual/bashref.html#Quoting

于 2011-12-22T05:30:33.210 に答える
4

重要: 使用しないでください:

--header="Content-Type: text/xml" 

--post-data とともに。オーバーライドします

--header="Content-Type: application/x-www-form-urlencoded" 

wget によって発行されます。Post-data は HttpServlet によって受信されません

于 2016-03-18T12:14:20.133 に答える