TMC is an independent, primarily volunteer organization that relies on ad revenue to cover its operating costs. Please consider whitelisting TMC on your ad blocker or making a Paypal contribution here: paypal.me/SupportTMC

Geeky: Tesla Build Status Monitoring script

Discussion in 'Model S: Ordering, Production, Delivery' started by linuxkidd, Sep 29, 2015.

  1. linuxkidd

    linuxkidd Member

    Joined:
    Sep 17, 2015
    Messages:
    44
    Location:
    Las Vegas (right now, but RV travel full time)
    Ok, so... like many who are waiting for their build.. I have been heavily abusing the refresh button on the build status page. I thought it may be nice to have a script to do this for me.. So, I wrote one.

    Geeky stuff below

    I'm a linux geek (as may be obvious by my username), so I wrote this in bash script, using the following command line tools:
    • cURL
    • links
    • awk
    • sed
    • grep
    • date
    These must be available for it to work properly. Note that the script is sloppy at best, and very fragile. e.g. if Tesla changes their status page layout, it'll likely break. It'll also likely not work quite right for those outside the US, although I'm sure that's an easy fix.. I just don't have access to those geos to know what changes are required. (PM me if you want my help making it work for your geo).

    If you'd like to see the script, you can do so on PasteBin at the following URL:
    http://pastebin.com/MR2q9JQZ

    Usage:
    From a terminal prompt:
    Code:
    wget "http://pastebin.com/raw.php?i=MR2q9JQZ" -O tesla_status.sh
    chmod 700 tesla_status.sh
    vi tesla_status.sh
    ./tesla_status.sh
    Note: You can of course edit the script with whichever editor you prefer (no need to learn vi). You must however edit the script to set your credentials and order id (details inside the script).

    Once you run the script, it'll generate a 'tesla_status.log' file in your home directory (name/path to this log is editable inside the script). Inside the log, you'll see a date/time stamped status output. This log will *only* have new lines added when the status is different from the previous check.

    Sample output:
    Code:
    2015-09-29 13:40:01 Model S,5YJSA1E22FF108569,Order Confirmed,Your Model S has entered the production queue at our Factory in Fremont, California.
    Happy to answer any questions!
    LK
     
  2. Stijn

    Stijn Member

    Joined:
    Aug 12, 2015
    Messages:
    149
    Location:
    BE
    Haha interesting project :) anyway on OS X it runs fine until line 71 - apparently links is not supported

    ./tesla.sh: line 70: links: command not found
     
  3. linuxkidd

    linuxkidd Member

    Joined:
    Sep 17, 2015
    Messages:
    44
    Location:
    Las Vegas (right now, but RV travel full time)
    #3 linuxkidd, Sep 30, 2015
    Last edited: Sep 30, 2015
    Cool, I hadn't thought to test it on my Mac.. I've now removed the dependency on 'links', and tested it
    OSX. Should be good to go (Updated pastebin, so same link as listed in post #1 above for the updated code).

    LK
     
  4. Stijn

    Stijn Member

    Joined:
    Aug 12, 2015
    Messages:
    149
    Location:
    BE
    Sorry LK but it's not working. I quickly logged on via my browser and intercepted the calls and it appears that it always uses the US auth service. My language is in English so it should be able to find the keywords. I don't get any output at all. Anything I can troubleshoot?
     
  5. linuxkidd

    linuxkidd Member

    Joined:
    Sep 17, 2015
    Messages:
    44
    Location:
    Las Vegas (right now, but RV travel full time)
    Hello Stijn,
    It must be the geo specific portions of the site are causing issues.

    I suspect the differences will be in the following areas:
    * Everything inside the <form...> ... <form/> tags on the login page
    - Any <input...> tag is represented in the second 'curl' call (I put each parameter on a separate line for easy troubleshooting)
    * The final status page url that shows the build status
    - This is present in the last 'curl' call

    If your not comfortable mucking around with this, feel free to save the source of these two pages and send them to me. I'm happy to confirm the differences and make the script more robust.
     
  6. linuxkidd

    linuxkidd Member

    Joined:
    Sep 17, 2015
    Messages:
    44
    Location:
    Las Vegas (right now, but RV travel full time)
    Hello Stijn,
    nothing looks particularly out of sorts with what you've provided vs what the script expects. I did update the script just a bit based on some other documentation regarding OSX sed vs linux sed.. I'd be curious to see if that corrects the issue for you.

    If not, please feel free to sanitize all the ~/.tesla_* files as you see fit, and send them to me so I can check the headers, etc...

    Thanks for helping troubleshoot this!
    LK
     
  7. Stijn

    Stijn Member

    Joined:
    Aug 12, 2015
    Messages:
    149
    Location:
    BE
    From the previous version of the script:


    LOG_FILE=~/tesla_status.log: contained date of first time running the script


    STATUS_FILE=~/.tesla_status: does not exist. .old and .new does, but are empty


    STATUS_FILE=~/.tesla_html: empty


    STATUS_FILE=~/.tesla_headers: does not exist. headers1 til 4 do exist, headers 1 for example contains
    HTTP/1.1 200 OK
    X-Cachecontrol-Changed: True
    X-LoggedIn: False
    ETag: "1123959647-3"
    X-UA-Compatible: IE=Edge
    Last-Modified: Sun, 04 Oct 2015 11:54:07 +0000
    X-Server: web07B
    Access-Control-Allow-Origin: *
    Content-Type: text/html; charset=utf-8
    X-Varnish-Server: sjc04p1wwwvr10.sjc05.teslamotors.com
    X-Frame-Options: SAMEORIGIN
    X-Cache-Hits: 0
    Expires: Sun, 04 Oct 2015 11:55:01 GMT
    Cache-Control: max-age=0, no-cache, no-store
    Pragma: no-cache
    Date: Sun, 04 Oct 2015 11:55:01 GMT
    Content-Length: 21038
    Connection: keep-alive




    COOKIE_FILE=~/.tesla_cookie: contains value below
    # Netscape HTTP Cookie File
    # http://curl.haxx.se/docs/http-cookies.html
    # This file was generated by libcurl! Edit at your own risk.


    .my.teslamotors.com TRUE / FALSE 1133291129 NO_CACHE Y
    #HttpOnly_.my.teslamotors.com TRUE / FALSE 1112391705 SESS001b8080c2d43535b7737e5b34cc1dc0 280e40a2saf2f0d3e3e539acf7a3de8553
    my.teslamotors.com FALSE //sites/all/modules/custom/tesla_sso/sso/ FALSE 2735415715 tesla_username stijn.xxxxx%xxxxx.be


    Using the new script, I removed all temp files and performed chmod 700 on the .sh. After running it I got this error:


    chmod: /Users/Stijn/.tesla_html: No such file or directory


    This is not the dir where my .sh is btw.
     

Share This Page