1

I am brand new at Python an i'm trying to followa basic programming cours from ciso/github. i am following some instructons verbatim, literally a cu n paste from some sample code, yet i still get syntax errors . can somebody telly me what is going wrong please?` her is my code

curl -k -x "https://10.85.116.30:443/restconf/data/Cisco-IOS-XE-native:native/logging/monitor/severity" \
-H 'Accept: application/yang-data+json' \
-u 'admin:admin'
  File "<input>", line 1
    curl -k -x "https://10.85.116.30:443/restconf/data/Cisco-IOS-XE-native:native/logging/monitor/severity" \
               ^
SyntaxError: invalid syntax
            ^
Roshin Raphel
  • 2,612
  • 4
  • 22
  • 40
Lowfell
  • 9
  • 1
  • 3

1 Answers1

2

You wrote a bash script. Not a python. Hence the syntax error. curl is a CLI program. Take a look on how to run CMD/CLI commands through python. Or use the ‘requests’ module within python to send an HTTP request.

Request module - https://requests.readthedocs.io/en/master/

Executing CLI in Python - How to execute a program or call a system command from Python?

CloudBalancing
  • 1,461
  • 2
  • 11
  • 22
  • Ok that makes sense and thank you. i am using Pycharm as an IDE, Can i run it from anywhere in there? All i can see apart from the python window is terminal window which just looks like windows cmd Can i run the curl from within pycharm anywhere? – Lowfell Jan 10 '21 at 08:09
  • BTW - if this answer is correct feel free to accept it as the correct answer (: – CloudBalancing Jan 10 '21 at 09:25