-1

I am using Robot Framework SSH Library - to perform the following operations.

  1. Connect to a remote machine via SSH
  2. Copy a python file into the remote machine. [The python file obtains the process with the ID specified]
  3. Run the python file using the execute command.

The issue I am facing is - Execute Command of robot framework does not return a result instead hangs. when I execute the python script via cmd-> ssh@remoteserver-> execute script - it executes perfectly fine.

below is the source code of the python file and robot framework code.

 command = f"Get-Process -Id {process_id} > {output_file}" result = subprocess.run(["powershell", "-Command", command], capture_output=True, text=True) 

I copy the python file from local to remote server via SSH Put File - all this works fine. only the execute command hangs!

${status}= Execute Command py ${remote_file_full_path} --id 11064 --output C:\\Sandeep\\process_output.txt 

Any idea how to resolve the same?

1
  • Why downvote!? Is the question too simple or did I misjudge asking the same? Commented 2 days ago

2 Answers 2

1

You can type commands directly in SSHLibrary session. If you python command outputs to the stdout, you can read id from the "screen".

Write python ${remote_file_full_path} --id 11064 --output /tmp/process_output.txt ${output}= Read # In this case you need to get the file 
Write powershell -Command Get-Process -Id ${process_id} ${output}= Read # In this case you need to process the output 
Sign up to request clarification or add additional context in comments.

Comments

1

I was able to solve the issue using following lines of code -

Please note - I still use Robot Framework SSH Library.

All this code is running from a .robot file and executes on a remote machine with a SSH connection open!

 ${part1} = Set Variable py ""${remote_file_full_path} ${part2} = Set Variable --id 11064 --output C:\\Sandeep\\process_output.txt"" ${part3} = Catenate ${part1} ${part2} ${status}= Execute Command ${part3} return_stderr=True return_stdout=True 

thanks!

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.