Run a python script in Redhat 7.4

Asked

Viewed 57 times

0

Good morning fellows

I made a script to integrate Telegram to Zabbix and forward the incidents.

The problem, the script only runs at the prompt using #python Telegram.py

However when I run #./Telegram it me error, below transcribe the script and right after the execution exit


! /usr/bin/python2

import telebot,sys

BOT_TOKEN='665333824:AAHTWQAz6dkS1bjpp9REu6RN-YHl_4cnTmU' DESTINATION=sys.argv[1] SUBJECT=sys.argv[2] MESSAGE=sys.argv[3]

MESSAGE = MESSAGE.replace('/n',' n')

tb = telebot.Telebot(BOT_TOKEN)

tb.send_message(DESTINATION,SUBJECT +' n' + MESSAGE)


xxx@zabbix:./telegram
./telegram: line 7: import: comando não encontrado
./telegram: line 14: erro de sintaxe próximo do `token' não esperado `('
./telegram: line 14: `MESSAGE = MESSAGE.replace('/n','\n')'

From what I’m seeing he thinks he’s a bash and not a python, how do I stop him to understand that he’s a python?

Thank you for your cooperation and good morning..

  • Basically what you need is to see the first line of your script: #! caminhoounomedoexecutavel - see reference links above

  • Well, that’s not the point, because it’s stated in the script, I re-edited my question by inserting the script.. if you can help thank you and unmark as duplicate, because the question should be another

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.