#[SOLVED] Running sed -i xxx in my container seems to work but the file is unchanged

1 messages · Page 1 of 1 (latest)

thick willow
#

Hi all

It should be stupid but ... I don't see it.

I've this Python code to do batch updates on my .env file; f..i.

// Partial code 

variables: dict[str, str] = {
    "APP_ENV": "testing",
    # "SESSION_DRIVER": "redis",
    # "SONAR_PROJECT_KEY": "xxxx",
}

for key, value in variables.items():
    ctr = await ctr.with_exec(
        ["sh", "-c", f"sed -i 's#\b{key}=.*\b#{key}={value}#' .env"],
        expect=ReturnType.SUCCESS,
    ).terminal()

So, I'm running (wish run) sed -i "s#\bAPP_ENV=.*\b#APP_ENV=testing#" .env in my container. I force expect=ReturnType.SUCCESS to throw an error if needed.

Going in my terminal and looking to my .env file : it's unchanged.

I've tried multiple approach for the with_exec (with sh -c; without, with single-quotes; with doubles, ...) but nothing works.

When I jump in the terminal and look if the change was done : no.

Did you see what I miss?

Note: I'm running under root and the .env file is owned by root so shouldn't be the problem.

Thanks !

thick willow
#

[SOLVED] Running sed -i xxx in my container seems to work but the file is unchanged