解析在bash脚本中运行的python脚本中的返回值

时间:2013-09-29 03:28:28

标签: bash google-apps

我正在尝试编写代码以从Google的GAM脚本中提取返回值。

我写了一个程序,看看如何返回值,并希望与它们互动,但我没有太多运气。以下是测试代码的样子:

#!/bin/bash
    gam_test(){
             OAUTHFILE=oauth.txt
            local gtestout=`~/gam/gam.py info user "$email" > test`
    }
    fname="April"
    lname="O'Neil"
    letter1=${fname:0:1}
    letter2=${lname:0:1}
    error_out="Error: 1301 - Entity AOkccp30@ga4edu.org Does Not Exist"
    concatemail=$letter1$letter2"kccp30@ga4edu.org"
    fullemail="AOkccp30@ga4edu.org"
    email=$fullemail
    gam_test
    sleep 5
    echo "---------"
    sleep 3
    echo $gtestout
    echo "---------"
    if [ "$error_out" -eq `gam_test` ]
            then
                    echo "Test 1 Success!! They are the same when you feed it emails!"
            else
                    echo "TEST 1 FAIL! WHAT DID YOU DO!?"
                    echo $error_out"/...test..../"
                    echo $gam_test"/....gam_test.../"
            fi
    email=$concatemail
    gtestout=$(python ~/gam/gam.py info user "$email" &)
    echo "---------"
    sleep 3
    echo $gtestout
    echo "---------"
    if [ "$error_out" == "$gtestout" ]
            then
                    echo "Test 2 Success!! They are the same when the program generates emails!"
            else
                    echo "TEST 2 FAIL! WHAT DID YOU DO!?"

我尝试过其他一些方法,但我似乎无法弄明白。

0 个答案:

没有答案