amoffat / sh

Python process launching

Home Page:https://sh.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Special kwarg _cwd and sh.pushd() not working

mnwdbase opened this issue · comments

i try:

with sh.pushd("/remote/dir"):
    my_server = sh.ssh.bake("root@1.2.3.4")
    my_server.npm("run")

ERROR: cannot find package.json in /root
how can fix?

sh.pushd only changes the current working directory of your local commands. it doesn't influence sh.ssh's remote cwd. advanced ssh usage is outside of the scope of provided support of this library.

iam only cd, is very simple command, cannot do it?

Do it on the command line first and you will see it doesn't work like you expect. Once you get it working on the commandline, then convert it to sh

@amoffat i can make ssh root@1.2.3.4 cd /remote/dir && npm run in commandline and works but with sh how can i make it?

You first need to learn how ssh runs command line arguments on a remote server, then it will become clear to you https://linux.die.net/man/1/ssh

In any case, this is not an sh issue.