0

I´m a network engineer with no experience in programming, recently in python, but making small improvements everyday.

I need some help in getting multiple matches in IF statements like:

if  "access-class 30" in output and "exec-timeout 5 5" in output:
    print ('###### ACL VTY OK!!! ######')

Is it possible to check multiple keywords in a single string ? Thanks for all your time.

1

2 Answers 2

1

Use the all function with a generator expression:

data = ["access-class 30", "exec-timeout 5 5"]
if all(s in output for s in data):
    print('###### ACL VTY OK!!! ######')
Sign up to request clarification or add additional context in comments.

Comments

0

Yes it is possible.

You can use regular expressions(Regex).

import re
li = [] # List of all the keywords
for l in li
  for m in re.finditer(l,output)
     if m !=None:
       print 'match found'

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.