1

I am trying to delete an ipmi user, using ipmitool and Linux. For this, I need to set their name to \xFF.

So I have a command that looks like this:

ipmitool -I lanplus -H 192.168.1.100 -U admin -P password user set name 4 $(echo -e '\xFF')

If I put it into the bash prompt, it works and the user gets deleted.

If I put it into a bash file, that goes like:

!#/bin/bash
ipmitool -I lanplus -H 192.168.1.100 -U admin -P password user set name 4 $(echo -e '\xFF')

And run it via:

Test Delete User By File
    ${rc}    ${output}=    Run And Return Rc And Output    ./delete_user.sh
    Should Be Equal As Integers    ${rc}    ${0}    msg="User not deleted"

It also works.

But when I run it this way

Test Delete User
    ${rc}    ${output}=    Run And Return Rc And Output    ipmitool -I lanplus -H 192.168.1.100 -U admin -P password user set name 4 $(echo -e '\\xFF')
    Should Be Equal As Integers    ${rc}    ${0}    msg="User not deleted"

It stops working and ipmitool complains that the arguments are wrong in some way.

And the one thing I have noticed, is that when run in bash the line echo -e '\xFF' gives me a symbol. But when I run it via ${rc} ${output}= Run And Return Rc And Output echo -e '\xFF' I get ÿ.

Now, I am running my code remotely on a Linux machine from a Windows system via an SSH tunnel. There's also someone using Linux to Linux who says it just works without any adjustments.

I did try adding and removing an additional backslash. I have also tried replacing the $(echo -e '\xFF') with Eval chr(255). It also gives me ÿ and ipmitool says:

Set User Name command failed (user 4, name ÿ): Invalid data field in request.

I have also tried writing some Python code to this, but it is not working either and has similar problems.

I assume the problem might be with the encoding or the environment, but what can I do to try and fix it?

slo
  • 55
  • 1
  • 3

2 Answers2

0

The problem come from how Robot Framework processes the command line parameter when using Run And Return Rc And Output. You should use Evaluate instead of directly inserting $(echo -e '\\xFF')

Do the following Robot Framework test case, Make sure to use only a single backslash (\xFF) when calling chr

*** Settings ***
Library    OperatingSystem

*** Test Cases ***
Test Delete User
    ${char_255} =    Evaluate    chr(255)
    ${rc}    ${output}=    Run And Return Rc And Output    ipmitool -I lanplus -H 192.168.1.100 -U admin -P password user set name 4 ${char_255}
    Should Be Equal As Integers    ${rc}    ${0}    msg="User not deleted"
Saxtheowl
  • 4,136
  • 5
  • 23
  • 32
0

The issue was resolved with

${rc} ${output} = Run And Return Rc And Output ipmitool -I lanplus -H 192.168.1.100 -U admin -P password user set name 4 $(bash -c "echo -e '\\xFF'")
mgmussi
  • 520
  • 1
  • 4
  • 19
slo
  • 55
  • 1
  • 3