Saturday, October 29, 2022

[SOLVED] How to add output parameter using sh

Issue

I have this Python script:

"""
Get a monitor's details returns "OK" response
"""
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v1.api.monitors_api import MonitorsApi

id = int(input("Write the monitor ID: "))
configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = MonitorsApi(api_client)
    response = api_instance.get_monitor(
        monitor_id=id,
    )

    print("Type:",response["type"])
    print("Name:",response["name"])
    print("State:",response["overall_state"])

How do I add a .sh script on linux that passes the monitor_id?


Solution

.sh file

python3 test.py arg1 arg2 arg3

.py file

import sys
arguments = sys.argv[1:]
print(arguments)
# ['arg1', 'arg2', 'arg3']


Answered By - Omer Dagry
Answer Checked By - Katrina (WPSolving Volunteer)