python
curl http://localhost/a/b
Ein Python-Skriptbeispiel, das die Ausgabe von Befehlen wie z.
launcher.py
#!/usr/bin/env python
import sys
import subprocess
d = {}
d['url1'] = {'ip': '192.168.1.1', 'path': '/'}
d['url2'] = {'ip': '192.168.2.2', 'path': '/path2'}
d['url3'] = {'ip': '192.168.3.3', 'path': '/path/file'}
d['url4'] = {'ip': '192.168.4.4', 'path': '/a/b'}
d['url5'] = {'ip': 'localhost', 'path': '/a/b'}
def _help():
print "[err] args need."
print sorted(d)
sys.exit(1)
def _cmd(key):
cmd = "curl.sh "+d[key]['ip']+" "+d[key]['path']
subprocess.call(cmd, shell=True)
if __name__ == '__main__' :
if len(sys.argv) == 1 : _help()
elif len(sys.argv) != 2 : _help("args wrong.")
_cmd(sys.argv[1])
curl.sh
#!/bin/sh
set -eu
ARG_IP=$1
ARG_PATH=$2
curl "http://${ARG_IP}${ARG_PATH}"
Recommended Posts