문제

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