Linux Commands in Excel

Hello experts greetings to you all,

I am a newbie

Here is my question; in my excel files linux commands are listed and placed in different cell address.
like:

A2 linuxcommand1
A5 linuxcommand1
A7 linuxcommand3
A100 linuxcommand4

now how will I pullout these linux commands using robotframework and execute them in a remoteserver?

If you can correct my code with the error below

*** Settings ***
Library SSHLibrary
Library ExcelLibrary

*** Variables ***
${HOST} 192.168.100.117
${USERNAME} root
${PASSWORD} Hitokiri
${PORT} 22
${EXCEL_FILE} D:/dev/linuxcommands.xlsx
${SHEET_NAME} Sheet1

*** Test Cases ***
Execute Commands On Remote Server
[Documentation] Execute commands on a remote Linux server
[Setup] Open Excel Document ${EXCEL_FILE} ${SHEET_NAME} mode=r
${ssh} Open Connection ${HOST} port=${PORT}
SSHLibrary.login ${USERNAME} ${PASSWORD}
@{command_cells}= Create List A2 A3 A5 A7 A10 A13 A22
FOR ${cell} IN @{command_cells}
${command}= Read Excel Cell ${SHEET_NAME} ${cell}
Run Keyword If ‘${command}’ != ‘’ Execute Command On Remote Server ${command}
END
[Teardown] Close All Connections

*** Keywords ***
Execute Command On Remote Server
[Arguments] ${command}
${output}= SSHLibrary.Execute Command ${HOST} ${USERNAME} ${PASSWORD} ${command}
Log ${output}

error: Execute Commands On Remote Server :: Execute commands on a remote … | FAIL |
ValueError: Argument ‘row_num’ got value ‘Sheet1’ that cannot be converted to integer.

thank you

the issue would seem to be this line:

image

If its the same library I Use then Read Excel Cell doesn’t require the sheetname passed as the first arg, but the row first and the col number second unless you prefix them, please see below:

Read Excel Cell row_num=1 col_num=1

I think most if not all excel libs, are the same in term of needing the row and col, docs do suggest you can pass sheet_name as third arg if the same library, but as you have that sheet open a little further up, you dont need to pass it:

Args:
row_num: row number, starts with 1.
col_num: column number, starts with 1.
sheet_name: sheet name, where placed cell, that need to be read.

But ulimately, its falling over as its expecting the row number, which your error speaks of yet its recieving text “Sheet1”:

image

Thanks

1 Like

Thank you for the reply I will try

1 Like