3

I want to execute the below commands in the Terminal using Robot Framework step by step. Any advice on how to go about it?

 1. ssh -o ProxyCommand\='ssh -W %h:%p xx.xx.xx.xx' xx.xvb.xyz.wq
 2. password
 3. sudo su - pentaho
 4. cd pentaho/design-tools/data-integration/
 5. sh kitchen.sh -file\=/ebs/pentaho/history/etljob.kjb
2
  • Why do you want to use RF for this? What are you trying to achieve? Commented Jun 17, 2020 at 7:48
  • That's a nice question. I am trying to automate end to end flow of my Database testing. Step 1 - I add test data in UI Step 2 - I run ETL jobs (Trying to achieve with above commands) Step 3 - Run regression queries in Database (Using RF DB Libs) Commented Jun 17, 2020 at 8:11

2 Answers 2

6

You can try using Process library.

Keyword like Run Process seems promising:

*** Settings ***
Library    Process     

*** Test Cases *** 
Python Tiny Program
    ${result} =     Run Process     python    -c    print('Hello, world!') 
    Log    ${result.stdout}

${result} will be an object, you can use various properties like stdout, stderr, rc and others. It's described in the official doc.

enter image description here

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for your advice. But I am not seeing the Result output of ${result.stdout}. It shows empty in my case.
Well, you can't interact with a shell in this way, so if you're expecting to get an interactive shell e.g. for login, this is not a good approach. And you'll see an output only for those commands that actually output something to the stdout etc.
So in order to execute the below commands, is this a correct way? ${Result}= Run Process python -c ssh -o ProxyCommand\='ssh -W %h:%p xx.xx.xx.xx' xx.xx.xx.xx Sleep 5s ${pwd1}= Run Process python -c 123xxx567 ${sudo}= Run Process python -c sudo su - pentaho
No, that's definitely not the right way. My answer was an example, you need to adapt it to your problem, I showed you the tools you might need for that. Run Process takes a shell command, I used python just as an example, you probably want to add the name of your script there. But as I said, you can't access an interactive shell like this, so typing your username and password is out of the question.
Thanks for correcting me! So how can I achieve above commands, by typing my username and password? Any advice?
0

You can run a terminal command like this:

*** Settings ***
Library    Process     

*** Test Cases *** 
Shell Program Testing
    ${result} =     Run Process     echo My name is Khan shell=true
    Log To Console    ${result.stdout}

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.