سؤال

Rhino is running in following directory

      /aaa/bbb/

and I need to launch another bash script in context of another directory:

      /xxx/zzz/script.sh

with all environment variable of its directory, especially PWD.

e.g. output of:

      runCommand("pwd", {env{pwd:"/xxx/zzz/"}});

should be:

      /xxx/zzz/

How can I properly define the environment variable? Thanks in advance!

هل كانت مفيدة؟

المحلول

You're just missing the correct syntax for the options object. Here's the example from the rhino shell documentation:

js> runCommand("sh", "-c", "echo $env1 $env2", { env: {env1: 100, env2: 200}})

So, you can do:

runCommand("sh","-c","cd $mydir && pwd", {env: {mydir: "/xxx/zzz"}})
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top