# How to provide input from keyboard to script. Input can be service name or application

**URL:** <https://discuss.elastic.co/t/how-to-provide-input-from-keyboard-to-script-input-can-be-service-name-or-application/358046>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [April 23, 2024, 4:13pm UTC](https://discuss.elastic.co/t/how-to-provide-input-from-keyboard-to-script-input-can-be-service-name-or-application/358046 "2024-04-23T16:13:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![navya\_k](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/navya_k/32/127091_2.png) [@navya\_k](https://discuss.elastic.co/u/navya_k)\
**Post date:** [April 23, 2024, 4:13pm UTC](https://discuss.elastic.co/t/how-to-provide-input-from-keyboard-to-script-input-can-be-service-name-or-application/358046/1 "2024-04-23T16:13:53Z")

</div>

Hello,

I have written below code to accept input from keyboard and retrieve data from elasticsearch cluster

```python
from elasticsearch import Elasticsearch
from datetime import datetime

es = Elasticsearch ("https://localhost", api_key="ACKRUSGHUSGHEHYFIRHU==")

Index_pattern = "test-*"
service_name = input("Enter service name: ")
query = {
  "query": {
     "bool": {
        "must": [
           {
             "range": {
                  "@timestamp": {
                      "gte": "now-1h"
         }
   }
},
{
 "term": {
      "service.name": 'service_name' #here using above declared variable
}
}
]
}
}
}
result = es.search(index=index_pattern, body=query)
for hit in result['hits'][hits']:
   Print(hit['_source])

```

When I execute the code asking for input but not retrieving data from. Elastic server. What is the mistake here ?

---

<div class="post-metadata">

**Author:** ![navya\_k](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/navya_k/32/127091_2.png) [@navya\_k](https://discuss.elastic.co/u/navya_k)\
**Post date:** [April 23, 2024, 4:21pm UTC](https://discuss.elastic.co/t/how-to-provide-input-from-keyboard-to-script-input-can-be-service-name-or-application/358046/2 "2024-04-23T16:21:32Z")

</div>

Please try to help here

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 23, 2024, 4:28pm UTC](https://discuss.elastic.co/t/how-to-provide-input-from-keyboard-to-script-input-can-be-service-name-or-application/358046/3 "2024-04-23T16:28:08Z")

</div>

Please be patient in waiting for responses to your question and refrain from pinging multiple times asking for a response or opening multiple topics for the same question. This is a community forum, it may take time for someone to reply to your question. For more information please refer to the [Community Code of Conduct](https://www.elastic.co/community/codeofconduct) specifically the section "Be patient". Also, please refrain from pinging folks directly, this is a forum and anyone that participates might be able to assist you.

If you are in need of a service with an SLA that covers response times for questions then you may want to consider talking to us about a [subscription](https://www.elastic.co/subscriptions).

It's fine to answer on your own thread after 2 or 3 days (not including weekends) if you don't have an answer.

---

<div class="post-metadata">

**Author:** ![Quentin\_Pradet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quentin_pradet/32/94192_2.png) [@Quentin\_Pradet](https://discuss.elastic.co/u/Quentin_Pradet)\
**Post date:** [April 24, 2024, 5:47am UTC](https://discuss.elastic.co/t/how-to-provide-input-from-keyboard-to-script-input-can-be-service-name-or-application/358046/4 "2024-04-24T05:47:38Z")

</div>

Hello! In addition to what David mentioned, here are other tips to make sure we can help you effectively:

- Use triple backticks to format your Python code: [Select the programming language used in code blocks - users - Discourse Meta](https://meta.discourse.org/t/select-the-programming-language-used-in-code-blocks/19247). I have edited your code to do that
- Please post code that is, to the best of your knowledge, correct, or at least starts running, before asking about higher-level Elasticsearch questions. Walk before you run.

I was about to give specific advice around quotes, but I just noticed that @jessgarson replied to [Test Rest API through python - #14 by jessgarson](https://discuss.elastic.co/t/test-rest-api-through-python/357531/14) with much more details than I would have. Please don't post duplicate questions like this. And let's focus on the other thread now.

---

<div class="post-metadata">

**Author:** ![Quentin\_Pradet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/quentin_pradet/32/94192_2.png) [@Quentin\_Pradet](https://discuss.elastic.co/u/Quentin_Pradet)\
**Post date:** [April 24, 2024, 5:47am UTC](https://discuss.elastic.co/t/how-to-provide-input-from-keyboard-to-script-input-can-be-service-name-or-application/358046/5 "2024-04-24T05:47:54Z")

</div>


