Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help needed: running a script #65

Open
thiagorova opened this issue Jun 13, 2018 · 0 comments
Open

help needed: running a script #65

thiagorova opened this issue Jun 13, 2018 · 0 comments

Comments

@thiagorova
Copy link

thiagorova commented Jun 13, 2018

Hi!
first of all, thanks a lot for this cool package.
I've been struggling for the past hour over something that I thought would be pretty simple... running a script using electron sudo, rather than just a command.
All of my attempts not only do nothing but the callbacks returns this error:

Unhandled rejection TypeError: cp.output.stdout is not a function
at /Library/WebServer/Documents/Upwork/download_booster/boostum-electron/main.js:158:15
at tryCatcher (/Library/WebServer/Documents/Upwork/download_booster/boostum-electron/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Library/WebServer/Documents/Upwork/download_booster/boostum-electron/node_modules/bluebird/js/release/promise.js:512:31)
at Promise._settlePromise (/Library/WebServer/Documents/Upwork/download_booster/boostum-electron/node_modules/bluebird/js/release/promise.js:569:18)
at Promise._settlePromise0 (/Library/WebServer/Documents/Upwork/download_booster/boostum-electron/node_modules/bluebird/js/release/promise.js:614:10)
at Promise._settlePromises (/Library/WebServer/Documents/Upwork/download_booster/boostum-electron/node_modules/bluebird/js/release/promise.js:693:18)
at Async._drainQueue (/Library/WebServer/Documents/Upwork/download_booster/boostum-electron/node_modules/bluebird/js/release/async.js:133:16)
at Async._drainQueues (/Library/WebServer/Documents/Upwork/download_booster/boostum-electron/node_modules/bluebird/js/release/async.js:143:10)
at Immediate.Async.drainQueues (/Library/WebServer/Documents/Upwork/download_booster/boostum-electron/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:789:20)
at tryOnImmediate (timers.js:751:5)
at processImmediate [as _immediateCallback] (timers.js:722:5)

Here's what I tried:

Os: macOS Sierra,
electron version: 2.0.2
electron-sudo version: 4.0.12

//startup code
var Sudoer = require('electron-sudo').default,
    sudo = new Sudoer({}),
    script_path = path.join(__dirname, "external", "shutdown.sh");
//I've also tried: script_path = path.join("external", "shutdown.sh");
//these were some of my attempts. I probably tried a couple others, but can't remember them right now
sudo.spawn('sh', ['$PARAM'], {env: {PARAM: script_path}})
    .then(function (cp) {                                                       //I used the same callback for all of them
        cp.output.stdout (Buffer)                                          //I didn't write it here to keep is concise 
        cp.output.stderr (Buffer)
    });
sudo.spawn('sh', [script_path], {}).then(function (cp) {});
sudo.spawn('sh', [script_path]).then(function (cp) {});
sudo.spawn(script_path, [], {}).then(function (cp) {});

the prompt screen appears and then... nothing. The script is supposed to wait until there is content in a particular file and, when there is, shutdown my computer.
I checked several times after turning the system on and there is content.

I've run the script independently and it works. I'm not sure if it's relevant, but here it is, anyway...

while [  ! -s external/shutdown_commander.txt ]; do
  sleep 5
done
> external/shutdown_commander.txt
shutdown -h now
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant