"context deadline exceeded" error when executing a code inside a machine

I am using fly machines’ rest api to create machine and execute code inside the machine.

my program code

#include <iostream>
#include <string>

int main() {
    std::string input;
    std::cout << "Please enter some text: ";
    std::getline(std::cin, input);
    std::cout << "You entered: " << input << std::endl;
    return 0;
}

input.txt

Hello, this is input from a file.

when I run ./program < input.txt it gives this err

{
    "error": "deadline_exceeded: Post \"http://unix/v1/exec\": context deadline exceeded"
}

why could this be failing in the fly machine?

is this error because of the input redirection?

Hi @77s—it looks like you’re running this with fly machines exec?

If so, then I think that the problem is that fly machines exec takes a raw command name and arguments. In this case, it’s running ./program with < and input.txt as arguments. It does not pass the command along to a shell (some minimal container images might not include a shell!) which would interpret the redirect.

If your image does contain a shell, then you can probably invoke it directly. E.g. if sh is available, you can try:

fly machines exec <id> 'sh -c "./program < input.txt"'
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.