Skip to content

Running command with run() returns command failed instead of storing variable #3216

@sts-ryan-holton

Description

@sts-ryan-holton
  • Deployer version: 6
  • Deployment OS: CentOS

I've created a custom deployer recipe with a task where I need to return the disk space of my server, here it is:

task('server:health:check', function () {
    $hostname = get('hostname');
    $free = run(`php -r 'echo disk_free_space("/");'`);
    
    // perform normal php functions and if statements here
});

The issue with this is it returns exit code 127, command not found:

The command "9441796096" failed.

Except this obviously isn't a command, I simply need the result of the run() method to store it's value inside of my $free variable, why isn't this working as I expect?

I also tried the following...

set('disk_space_free', function () {
    return run('disk_free_space("/")');
});

Thinking that with the return I could then output {{ disk_space_free }} in another run command, same result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions