How do you spend a P2SH transaction? I've been running into a lot of trouble getting a transaction to spend coins in a multisig address.

I create the raw transaction
When I go to sign, I get "Operation not valid with the correct stack size"

I'm using core, and the codes are here.

First, check if it's good.

bitcoin-cli decoderawtransaction 0100000001d2aba456546be8f5223802112637e484c5d94118dfe560fa23de06fb37e621dd0000000000ffffffff01107a0700000000001976a914a4f29e1c8f592021fd79eda1be85c96a9a8d349a88ac00000000
{
    "txid" : "e71006c60dbfa2793710d5cf866d1b6b89ba80bc41634031d927738c40ae8228",
    "version" : 1,
    "locktime" : 0,
    "vin" : [
        {
            "txid" : "dd21e637fb06de23fa60e5df1841d9c584e4372611023822f5e86b5456a4abd2",
            "vout" : 0,
            "scriptSig" : {
                "asm" : "",
                "hex" : ""
            },
            "sequence" : 4294967295
        }
    ],
    "vout" : [
        {
            "value" : 0.00490000,
            "n" : 0,
            "scriptPubKey" : {
                "asm" : "OP_DUP OP_HASH160 a4f29e1c8f592021fd79eda1be85c96a9a8d349a OP_EQUALVERIFY OP_CHECKSIG",
                "hex" : "76a914a4f29e1c8f592021fd79eda1be85c96a9a8d349a88ac",
                "reqSigs" : 1,
                "type" : "pubkeyhash",
                "addresses" : [
                    "1G3ATq31k5SrGdqucXKqA9dHbzS3wJHzbc"
                ]
            }
        }
    ]
}


And then we go to sign.

bitcoin-cli signrawtransaction 0100000001d2aba456546be8f5223802112637e484c5d94118dfe560fa23de06fb37e621dd0000000000ffffffff01107a0700000000001976a914a4f29e1c8f592021fd79eda1be85c96a9a8d349a88ac00000000
{
    "hex" : "0100000001d2aba456546be8f5223802112637e484c5d94118dfe560fa23de06fb37e621dd000000009200483045022100eaae5737ab000f614ce73da11ba456b4467cf640ed881fd1fa90183d1d28c2e8022066c78bf750ae0a175f6ef116ecc3e4a0c18eda1aff9c951952f8f6e45a3521ad0147522102908921b30aa37fe6e522c528cca0ebcda9f0df4019301fa45bc3b3c7df60245a2103559dc92d6e44a98080d487e585b93278106249a166795584ae554a4275f059b752aeffffffff01107a0700000000001976a914a4f29e1c8f592021fd79eda1be85c96a9a8d349a88ac00000000",
    "complete" : false,
    "errors" : [
        {
            "txid" : "dd21e637fb06de23fa60e5df1841d9c584e4372611023822f5e86b5456a4abd2",
            "vout" : 0,
            "scriptSig" : "00483045022100eaae5737ab000f614ce73da11ba456b4467cf640ed881fd1fa90183d1d28c2e8022066c78bf750ae0a175f6ef116ecc3e4a0c18eda1aff9c951952f8f6e45a3521ad0147522102908921b30aa37fe6e522c528cca0ebcda9f0df4019301fa45bc3b3c7df60245a2103559dc92d6e44a98080d487e585b93278106249a166795584ae554a4275f059b752ae",
            "sequence" : 4294967295,
            "error" : "Operation not valid with the current stack size"
        }
    ]
}


I'm using https://gist.githubusercontent.com/gavinandresen/3966071/raw/ca21870c190ba0e90c1a30673e790ef5acd207d2/TwoOfThree.sh for reference.
You get this error because Bitcoin has tried to validate the script, and failed, because not all of the signatures necessary were added in the previous signrawtransaction. You can also tell this because complete is false.

You need to take it to clients that have the other keys necessary, and run signrawtransaction on the transaction there too.