3

I have a node lambda function from which i'am running a bash script.

'use strict';

const exec = require('child_process').exec;

exports.handler = (event, context, callback) => {
    const message = event.message;
    const child = exec('./bs.sh ' + message, function(err, stdout, stderr) {
    console.log(stdout);
    console.log(stderr);
    });
};

When i run this, i get /bin/sh: ./bs.sh: Permission denied . I tried changing permissions with chmod 777 bs.sh before zipping the function, but that too didn't work. Is it a limitation of lambda or an error in my approach?

2
  • btw: you shoud check for err and call callback. function(err, stdout, stderr) { if (err) { callback(err); } else { console.log(stdout); console.log(stderr); callback(); } }); Commented Dec 1, 2016 at 7:29
  • stackoverflow.com/questions/34629574/… Commented Dec 1, 2016 at 8:03

1 Answer 1

1

You'll want to look at

https://aws.amazon.com/blogs/compute/running-executables-in-aws-lambda/

In particular this bit:

Including your own executables is easy; just package them in the ZIP file you upload, and then reference them (including the relative path within the ZIP file you created) when you call them from Node.js or from other processes that you’ve previously started. Ensure that you include the following at the start of your function code:

process.env['PATH'] = process.env['PATH'] + ':' + process.env['LAMBDA_TASK_ROOT']
Sign up to request clarification or add additional context in comments.

1 Comment

I tried this for executable binaries and I get Permission denied

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.