-
Notifications
You must be signed in to change notification settings - Fork 15
Passing arguments to a script
Svein Arne Ackenhausen edited this page May 10, 2014
·
2 revisions
Most commands will want some type of arguments passed to it. When the script is run the first three arguments are the location where the script is run, name of the global profile and name of the local profile.
This sample is in python as I enjoy using python. You can use any language you want
#!/usr/bin/env python
import sys
def print_definitions():
print("Runs a script with arguments|")
print("NAME|\"Name of the person to greet\" end")
def run_command(run_location, global_profile, local_profile, args):
if len(args) == 0:
print("error|You must pass the argument NAME as the person you want to greet")
return
print("Hello "+args[0]+"!")
if __name__ == "__main__":
args = sys.argv
if len(args) > 1 and args[2] == 'get-command-definitions':
print_definitions()
else:
run_command(args[1], args[2], args[3], args[4:])