Shell script / Python / Node / Newb lost ...

Posted on
Mon Apr 23, 2018 9:05 pm
DaveL17 offline
User avatar
Posts: 5102
Joined: Aug 20, 2013
Location: Chicago, IL, USA

Re: Shell script / Python / Node / Newb lost ...

@howartp, you mean like this?

Code: Select all
import subprocess

command = ["/Users/myriam/.nvm/versions/node/v9.11.1/bin/ps4-waker", "standby", "-t", "30000", "env=node"]

proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

out, err = proc.communicate()

indigo.server.log(u"command error: %s" % err)

or something akin to that....

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Mon Apr 23, 2018 9:12 pm
howartp offline
Posts: 3778
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Shell script / Python / Node / Newb lost ...

No.

subprocess.popen(command, err=stdpipe, out=stdpipe, env=node, shell=true)

That’s the shrunk version of what I mean...


Sent from my iPhone using Tapatalk Pro

Posted on
Mon Apr 23, 2018 9:28 pm
pmgendon offline
Posts: 35
Joined: Apr 20, 2015

Re: Shell script / Python / Node / Newb lost ...

howartp wrote:
No.

subprocess.popen(command, err=stdpipe, out=stdpipe, env=node, shell=true)

That’s the shrunk version of what I mean...


Sent from my iPhone using Tapatalk Pro


you guys are machines!!

Here's the code I ran:
Code: Select all
import subprocess


command = ["/Users/myriam/.nvm/versions/node/v9.11.1/bin/ps4-waker", "standby", "-t", "30000"]

proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=node, shell=true)

out, err = proc.communicate()

indigo.server.log(u"command error: %s" % err)



Here's the error I'm now having:

Script Error embedded script: global name 'node' is not defined
Script Error Exception Traceback (most recent call shown last):

embedded script, line 6, at top level
NameError: global name 'node' is not defined

Posted on
Mon Apr 23, 2018 9:34 pm
howartp offline
Posts: 3778
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Shell script / Python / Node / Newb lost ...

Code: Select all
import subprocess

command = "/usr/local/bin/ps4-waker standby -t 30000"

proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=‘node’, shell=True)

out, err = proc.communicate()

indigo.server.log(u"command error: %s" % err)

I’m thinking this?

I’ve reverted command back to my second reply about [commands, like, this].

I’ve also set path back to /usr/local/bin as I think that’s how you originally ran it - the env node should automatically find the path to /Miriam/.../node/.... etc without hard coding it, I think.


Sent from my iPhone using Tapatalk Pro

Posted on
Mon Apr 23, 2018 10:01 pm
pmgendon offline
Posts: 35
Joined: Apr 20, 2015

Re: Shell script / Python / Node / Newb lost ...

howartp wrote:
Code: Select all
import subprocess

command = "/usr/local/bin/ps4-waker standby -t 30000"

proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=‘node’, shell=True)

out, err = proc.communicate()

indigo.server.log(u"command error: %s" % err)

I’m thinking this?

I’ve reverted command back to my second reply about [commands, like, this].

I’ve also set path back to /usr/local/bin as I think that’s how you originally ran it - the env node should automatically find the path to /Miriam/.../node/.... etc without hard coding it, I think.


Sent from my iPhone using Tapatalk Pro


Getting a different error this time

Script Error embedded script: execve() arg 3 must be a mapping object
Script Error Exception Traceback (most recent call shown last):

embedded script, line 5, at top level
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
TypeError: execve() arg 3 must be a mapping object

Posted on
Mon Apr 23, 2018 10:27 pm
pmgendon offline
Posts: 35
Joined: Apr 20, 2015

Re: Shell script / Python / Node / Newb lost ...

let's complicate things a bit !!!

I did not have a /usr/bin/node folder. I created one and created a symlink to the /Users/myriam/.nvm/versions/node/v9.11.1/bin/.

I ran the code again and I'm now getting the following error:

Script command error: env: node: Permission denied

Posted on
Tue Apr 24, 2018 12:21 am
howartp offline
Posts: 3778
Joined: Jan 09, 2014
Location: West Yorkshire, UK

Re: Shell script / Python / Node / Newb lost ...

You don’t need a usr/bin/node folder.

https://scriptingosx.com/2017/10/on-the-shebang/ is a good explanation of the shebang line, which explains env as a magic way of finding where node is installed.


Sent from my iPhone using Tapatalk Pro

Posted on
Wed Apr 25, 2018 10:42 am
pmgendon offline
Posts: 35
Joined: Apr 20, 2015

Re: Shell script / Python / Node / Newb lost ...

howartp wrote:
You don’t need a usr/bin/node folder.

https://scriptingosx.com/2017/10/on-the-shebang/ is a good explanation of the shebang line, which explains env as a magic way of finding where node is installed.


Sent from my iPhone using Tapatalk Pro


that was an interesting read. I went ahead and removed the symlink.

Now i'm back to this error:

Script Error embedded script: execve() arg 3 must be a mapping object
Script Error Exception Traceback (most recent call shown last):

embedded script, line 5, at top level
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
TypeError: execve() arg 3 must be a mapping object

Who is online

Users browsing this forum: No registered users and 2 guests