execute time period in python
<p>I want to run the script in shell by sending time period like</p>

<pre><code>./test.py 20160830000 201608311100
</code></pre>

<p>How can I do this for the following python script?
<code>s</code> and <code>t</code> are UNIX timestamp.</p>

<pre><code>#!/usr/bin/python
import requests
from pprint import pprint
import json
import os
import commands
i =  commands.getstatusoutput('date -d "2016-08-30" "+%s"')
j =  commands.getstatusoutput('date -d "2016-08-31" "+%s"')
s = int(i[1])
t = int(j[1])
url = 'http://192.168.1.96/zabbix/api_jsonrpc.php'
payload = {
    "jsonrpc": "2.0",
    "method": "history.get",
    "params": {
        "output": "extend",
        "history": 0,
        "time_from": s,
        "time_till": t,
        "hostsids": "10105",
        "itemids": "23688",
        "sortfield": "clock",
        "sortorder": "DESC"
    },
    "auth": "b5f1f71d91146fcc2980e83e8aacd637",
    "id": 1
}

header = {
    'content-type': 'application/json-rpc',
}
res  = requests.post(url, data=json.dumps(payload, indent=True), headers=header)
res = res.json()
pprint(res)
</code></pre>

<p>Take a look at the <a href="https://docs.python.org/2/library/time.html" rel="nofollow">time</a> python module, specifically the <a href="https://docs.python.org/2/library/time.html#time.strptime" rel="nofollow">time.strptime</a> function for parsing human-readable time strings into a time structure and the <a href="https://docs.python.org/2/library/time.html#time.mktime" rel="nofollow">time.mktime</a> function for converting a time structure into a unix timestamp.</p>

python json linux