Set up environment

Command line tool (clt)

Amazon Mechanical Turk provides a command line tool that could be used for us to upload experiments and download results right from our desktop computer. The command line tool can be downloaded here:https://requester.mturk.com/developer/tools/clt

Unzip the file, we get a folder called aws-mtukr-clt-1.3.4. Now open the Terminal on Mac. Navigate to the folder where aws-mtukr-clt-1.3.4 is. Go to the “bin” folder.

The “cd” command is used to navigate to the folder. “cd” stands for “changing directory”.

Zhiyans-MBP:~ zhiyangao$ cd Docs/aws-mtukr-clt-1.3.4/bin
Zhiyans-MBP:bin zhiyangao$ 

We are not ready to use the command line tool just yet. There are 2 other things to download.

Download required Java software

The latest Oracle JDK and JRE are needed. Download both from here:https://www.oracle.com/technetwork/java/javase/downloads/index.html

Ignore this if you already have java JDK and JRE installed. You can test you Java environment by typing “java -version” in your Terminal console (Mac) or Command Line Prompt (Windows). I did it on my Mac and here’s what it shows. This means I have Java version 1.8.0_191 on my computer.

Zhiyans-MacBook-Pro:zhiyangao$ java -version
  java version "1.8.0_191"
  Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
  Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

Set JAVA_HOME (on Mac)

Once JDK and JRE are installed. We need to set JAVA_HOME (There’s no need to understand why we are doing this). Copy the “export JAVA_HOME=/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/” into your Terminal console.

Zhiyans-MBP:bin zhiyangao$ 
export JAVA_HOME=/Library/Internet\Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/

Zhiyans-MBP:bin zhiyangao$ 

Setting up JAVA_HOME on Windows could be done through Control Panel. First find the JDK folder directory (It should be in the “C:/Program Files” folder by default ), and then open Control Panel, find “system”, click environment settings, click on JAVA_HOME, type the JDK directory in it. Click OK.

Set up MTurk account

Change mturk.properties file

Go to the aws-mturk-clt-1.3.4 folder, open “bin” folder, The “mturk.properties” file is in there. Open it with a test editor (e.g. TextEdit on Mac).

Now the access_Key and secret_Key are empty. We need to put in there the Keys associated with our Amazon AWS account, which means we need an Amazon AWS account.

Go and register one: https://aws.amazon.com/. Have your credit card ready.

Sign in your account, click on “my security credentials”. You will see a page where you can get the two keys. Click on Access keys to create access_key and secret_key. Download the root csv file containing these keys.

Paste the keys into the mturk.properties file. Don’t include the “[ ]”s, just the keys (Note:The keys in the following picture are made-up)

Sandbox setting

Notice in the picture above, there’s line saying:

service_url=https://mechanicalturk.sandbox.amazonaws.com/?Service=AWSMechanicalTurkRequester

This means whatever we do will stay in the “sandbox”. This is fine when we are just testing our experiments. If we want to do it for real, then we need to remove the “.sandbox” part. I am not going to do that right now.

Let’s go back to the Terminal. Type ./getBalance.sh (get/Result.cmd for Windows Users). Amazon tells me that I got $10000 to spend. This would be nice if it were true.

Zhiyans-MBP:bin zhiyangao$ ./getBalance.sh 
Your account balance: $10000

Remember that we are in the “sandbox”. No real money is involved here. By typing ./getBalance,sh, I asked MTurk comand line tool to communicate with its server and ask about my account balance. It did so, and found that I am using a sandbox setting. So it replies back $10000, wich means the communication is successful, which means we have set up the comand line tool correctly.

Do it for real

I am going to remove the “.sandbox” from the mturk.properties file. The line now reads:

service_url=https://mechanicalturk.amazonaws.com/?Service=AWSMechanicalTurkRequester

Now let’s see how much money I really got, by typing ./getBalance.sh again. On your computer, it could be 0, because you never deposit any money on your MTurk account. MTurk calls it “purchasing HITs”.

Zhiyans-MBP:bin zhiyangao$ ./getBalance.sh 
Your account balance: $61.30

Now the MTurk command line tool is linked to my account, and ready to take commands from me.

If you are getting crazy error messages, then you need to check if Java JDK and JRE are installed correctly, and if JAVA_HOME has been set up correctly.

Ask Google

Things in the Tech world are changing rapidly. The things that work today might not work tomorrow. The steps I mentioned here might not work in the future. We need to ask google when that time comes. For now, if any of the terms (e.g. Terminal Console, Command Line Prompt, Control Panel etc.) mentioned above is new to you, please just google it.