0

I've uploaded a zip file with ffmpeg for lambda. I've run a ls -l command to verify the ffmpeg utility is there and it was (no permissions though). To have it run I understand that i need to copy it to /tmp folder and changed the permissions there. I've tried to do this with: /bin/sh -c echo 'step0' && cp /var/task/ffmpeg /tmp && echo 'step1' && chmod 755 /tmp/ffmpeg && echo 'step2' && ls /tmp/ but all I see is the step0 in the output of the test lambda functionality. It seems that the copy command fails somehow. NB: I'm using a java lambda but I don't see how this can make a difference at this level because the lambda call and command seems to pass through. Many thanks.

UPDATE:

public class Lambda implements RequestHandler<FragmentsRequest, String> {
@Override
public String handleRequest(final FragmentsRequest input, final Context context) {
    final List<String> command = Stream.of(input.getCommand().split(",")).collect(Collectors.toList());
    final String output = runCommandForOutput(command);
    return output;
}

public static String runCommandForOutput(List<String> params) {
    final ProcessBuilder pb = new ProcessBuilder(params);
    Process p;
    String result = "";
    try {
        p = pb.start();
        final BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));

        final StringJoiner sj = new StringJoiner(System.getProperty("line.separator"));
        reader.lines().iterator().forEachRemaining(sj::add);
        result = sj.toString();

        p.waitFor();
        p.destroy();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}
}
Daniel Jipa
  • 878
  • 11
  • 24
  • Hi Daniel, could you add to your question how you are running these commands? From a terminal on your machine? I'm not a Java expert but I think it might help getting more insight on your problem. – Yves Gurcan Dec 12 '19 at 19:42
  • From a ProcessBuilder in Java code. I can paste the code if needed – Daniel Jipa Dec 12 '19 at 19:54
  • Have you referenced this? https://stackoverflow.com/questions/36063411/aws-lambda-permission-denied-when-trying-to-use-ffmpeg – Ethan Harris Dec 13 '19 at 00:46
  • Yes, I've mentioned that the copy to tmp folder command failed. – Daniel Jipa Dec 13 '19 at 06:55
  • To copy from /var/task/ to /tmp/ you can do this ```Files.move(Paths.get(file.toURI()), Paths.get(path.toAbsolutePath().toUri()), StandardCopyOption.REPLACE_EXISTING);``` ```Source``` ```destination``` and ```mode``` in that order – Arjun Kalidas Feb 13 '23 at 22:15

0 Answers0