title: How to send the ouput of show command to custom library of Robot framework?
body: <p>I am planning to automate the following scenario:</p>
  
  <pre><code>STEP 1 : Launch gmail page in firefox browser
  STEP 2 : Enter username and password
  STEP 3 : Press signin button
  STEP 4 : When above 3 steps are happening, my router will recognize as gmail traffic and show in "show dpi app stats gmail on AVC/test-15E8CC" command output.
  STEP 5 : Custom library should check the output of above show command and decide whether test is FAIL or PASS
  </code></pre>
  
  <p>For the above purpose I have written "pass_fail.robot" as shown below:</p>
  
  <pre><code>*** Settings ***
  Library         Selenium2Library
  Library         SSHLibrary
  Library         regexp_def.py
  Suite Setup     Go to gmail page
  Suite Teardown  Close All Browsers
  
  *** Variables ***
  ${HOMEPAGE}     https://www.gmail.com/intl/en/mail/help/about.html
  ${BROWSER}      firefox
  ${LOGINPAGE}    https://www.gmail.com/intl/en/mail/help/about.html
  ${FINALURL}     https://mail.google.com/mail/
  ${FINALURL1}    https://accounts.google.com/ServiceLogin?service=mail&amp;continue=https://mail.google.com/mail/'
  
  ${HOST}             1.1.1.1
  ${USERNAME}         test
  ${PASSWORD}         test
  
  *** Test Cases ***
  Login into gmail
      Go to gmail page
  Login Page Should Be Open
      Click Signin Button
  Input Username      test@gmail.com
  Input Password      test@123
  Submit Credentials
  Inbox page should open
  
  Check Deep Packet Inspection Stats
      Open Connection         ${HOST}
      enable ssh logging      XYZ
      Login   ${USERNAME}     ${PASSWORD}
      Write                   enable
      Write                   show dpi app stats gmail on AVC/switch-15E8CC
      ${x}                    Read Until Regexp       .*#
  
  Check Pass Fail Criteria
      pass fail criteria
  
  
  
  *** Keywords ***
  Go to gmail page
      Open Browser    ${HOMEPAGE}     ${BROWSER}
      Maximize Browser Window
  
  Login Page Should Be Open
      Location Should Be      ${LOGINPAGE}    
  
  Click Signin Button
      Click Element       id=gmail-sign-in
  
  Input Username
      [Arguments]     ${username}
      Input Text      id=Email    ${username}
  
  
  Input Password
      [Arguments]     ${password}
      Input Text      id=Passwd   ${password}
  
  Submit Credentials
      Click Button    id=signIn
  
  Inbox page should open
      Location Should Be      ${FINALURL}
  </code></pre>
  
  <p>My custom Library "regexp_def.py" is looks like this:</p>
  
  <pre><code>import re
  
  '''
  
  #Following is the sample content of x variable should get from robot framework:
  
  
  x="""router-7F2C13#show app stats gmail on TEST/switch1234-15E8CC
    --------------------------------------------------------------------------------
       APPLICATION           BYTES_IN         BYTES_OUT           NUM_FLOWS
  --------------------------------------------------------------------------------
    gmail                0                 0                  0
  --------------------------------------------------------------------------------
  router-7F2C13#
  ---------------------------------------------------------------
  router-7F2C13#"""
  '''
  
  
  def pass_fail_criteria():
      if int(re.findall(r"NUM_FLOWS\n-+[\s\S]*?(\d+)\s*-+",x)[0]):
          print "pass"
      else:
          print "fail"
  
  pass_fail_criteria()
  </code></pre>
  
  <p>When I run this test I am getting following error:</p>
  
  <pre><code>C:\Users\test\Desktop\Projects\gmail_stats_with_pass_fail_criteria&gt;pybot pass_
  fail.robot
      [ ERROR ] Error in file 'C:\Users\test\Desktop\Projects\gmail_stats_with_pass_
  fail_criteria\pass_fail.robot': Importing test library 'C:\Users\test\Desktop\
  Projects\gmail_stats_with_pass_fail_criteria\regexp_def.py' failed: NameError: g
  lobal name 'x' is not defined
  Traceback (most recent call last):
    File "C:\Users\test\Desktop\Projects\gmail_stats_with_pass_fail_criteria\reg
      exp_def.py", line 26, in &lt;module&gt;
  pass_fail_criteria()
    File "C:\Users\test\Desktop\Projects\gmail_stats_with_pass_fail_criteria\reg
  exp_def.py", line 21, in pass_fail_criteria
      if int(re.findall(r"NUM_FLOWS\n-+[\s\S]*?(\d+)\s*-+",x)[0]):
  PYTHONPATH:
    C:\Python27\lib\site-packages\robot\libraries
    c:\python27\lib\site-packages\pycrypto-2.6-py2.7-win32.egg
    C:\Python27\lib\site-packages
    C:\Python27\Lib
    C:\Windows\system32\python27.zip
    C:\Python27\DLLs
    C:\Python27\lib\plat-win
    C:\Python27\lib\lib-tk
    C:\Python27
    C:\Python27\lib\site-packages\win32
    C:\Python27\lib\site-packages\win32\lib
    C:\Python27\lib\site-packages\Pythonwin
    C:\Python27\lib\site-packages\wx-2.8-msw-unicode
    .
      ==============================================================================
  Pass Fail
      ==============================================================================
  Login into gmail                                                      | PASS |
  ------------------------------------------------------------------------------
  Check Deep Packet Inspection Stats                                    | PASS |
  ------------------------------------------------------------------------------
  Check Pass Fail Criteria                                              | FAIL |
  No keyword with name 'pass fail criteria' found.
  ------------------------------------------------------------------------------
  Pass Fail                                                             | FAIL |
  3 critical tests, 2 passed, 1 failed
  3 tests total, 2 passed, 1 failed
   ==============================================================================
  Output:  C:\Users\test\Desktop\Projects\gmail_stats_with_pass_fail_criteria\ou
  tput.xml
  Log:     C:\Users\test\Desktop\Projects\gmail_stats_with_pass_fail_criteria\lo
  g.html
  Report:  C:\Users\test\Desktop\Projects\gmail_stats_with_pass_fail_criteria\re
  port.html
  
   C:\Users\test\Desktop\Projects\gmail_stats_with_pass_fail_criteria&gt;
  </code></pre>
  
  <p>Could any one please look into this. </p>
  
  <p>I am seeing problem in sending required data (output of show command to "${x}") to the custom library .</p>
  
  <p>Is there any other issue. Please guide me on this.</p>
  
  <h1>New files modified as per "Bryan Oakley" comments:</h1>
  
  <p>regexp_def.py file contents:</p>
  
  <pre><code>import re
  
  def pass_fail_criteria():
      if int(re.findall(r"NUM_FLOWS\n-+[\s\S]*?(\d+)\s*-+",x)[0]):
          return "pass"
      else:
          return "fail"
  </code></pre>
  
  <p>pass_fail.robot file contents:</p>
  
  <pre><code>*** Settings ***
  Library         Selenium2Library
  Library         SSHLibrary
  Library         regexp_def.py
  Suite Setup     Go to gmail page
  Suite Teardown  Close All Browsers
  
  *** Variables ***
  ${HOMEPAGE}     https://www.gmail.com/intl/en/mail/help/about.html
  ${BROWSER}      firefox
  ${LOGINPAGE}    https://www.gmail.com/intl/en/mail/help/about.html
  ${FINALURL}     https://mail.google.com/mail/
  ${FINALURL1}    https://accounts.google.com/ServiceLogin?service=mail&amp;continue=https://mail.google.com/mail/'
  
  ${HOST}             10.1.1.2
  ${USERNAME}         admin
  ${PASSWORD}         moto
  
  *** Test Cases ***
  Login into gmail
      Go to gmail page
      Login Page Should Be Open
      Click Signin Button
      Input Username      zebradtc@gmail.com
      Input Password      Zebra@123
      Submit Credentials
      Inbox page should open
  
  Check Deep Packet Inspection Stats
      Open Connection         ${HOST}
      enable ssh logging      XYZ
      Login   ${USERNAME}     ${PASSWORD}
      Write                   enable
      Write                   show dpi app stats gmail on AVC/ap7532-15E8CC
      ${x}                    Read Until Regexp       .*#
  
  Check Pass Fail Criteria
      ${result}   pass fail criteria      ${x}        
  
  
  
  
  *** Keywords ***
  Go to gmail page
      Open Browser    ${HOMEPAGE}     ${BROWSER}
      Maximize Browser Window
  
  Login Page Should Be Open
      Location Should Be      ${LOGINPAGE}    
  
  Click Signin Button
      Click Element       id=gmail-sign-in
  
  Input Username
      [Arguments]     ${username}
      Input Text      id=Email    ${username}
  
  Input Password
      [Arguments]     ${password}
      Input Text      id=Passwd   ${password}
  
  Submit Credentials
      Click Button    id=signIn
  
  Inbox page should open
      Location Should Be      ${FINALURL}
  
  
  #${status}          pass fail criteria
  should be equal    ${status}             pass
  
  
  # pass ${x} to the custom keyword
  ${result}          Pass fail criteria      ${x} 
  </code></pre>
  
  <p>After modifying these files I am getting following error:</p>
  
  <pre><code>C:\Users\symbol\Desktop\Projects\gmail_stats_with_pass_fail_criteria&gt;pybot pass_
  fail.robot
  ==============================================================================
  Pass Fail
  ==============================================================================
  Login into gmail                                                      | FAIL |
  Parent suite setup failed:
  Keyword '${result}' expected 0 arguments, got 2.
  ------------------------------------------------------------------------------
  Check Deep Packet Inspection Stats                                    | FAIL |
  Parent suite setup failed:
  Keyword '${result}' expected 0 arguments, got 2.
  ------------------------------------------------------------------------------
  Check Pass Fail Criteria                                              | FAIL |
  Parent suite setup failed:
  Keyword '${result}' expected 0 arguments, got 2.
  ------------------------------------------------------------------------------
  Pass Fail                                                             | FAIL |
  Suite setup failed:
  Keyword '${result}' expected 0 arguments, got 2.
  
  Also suite teardown failed:
  Variable '${x}' not found.
  
  3 critical tests, 0 passed, 3 failed
  3 tests total, 0 passed, 3 failed
  ==============================================================================
  Output:  C:\Users\symbol\Desktop\Projects\gmail_stats_with_pass_fail_criteria\ou
  tput.xml
  Log:     C:\Users\symbol\Desktop\Projects\gmail_stats_with_pass_fail_criteria\lo
  g.html
  Report:  C:\Users\symbol\Desktop\Projects\gmail_stats_with_pass_fail_criteria\re
  port.html
  
  C:\Users\symbol\Desktop\Projects\gmail_stats_with_pass_fail_criteria&gt;
  </code></pre>