简体   繁体   中英

How can I run a shell script via SSH such that the environment of the remote computer is similar to that of the local computer?

I welcome rephrasing of my question, because I'm not sure exactly what the problem is called.

I am trying to run a shell script via SSH using a command of the following form:

ssh -o StrictHostKeyChecking=no lxplus0035 "cd ~/test; bash script1.sh"

When I do this, the complex script script1.sh breaks with many syntax errors, operand errors and other errors. An example is as follows:

stty: standard input: Invalid argument

The script works fine when run directly, not via SSH, in the local system and in the remote system (when connected in an SSH session). Why might executing the script via SSH cause these problems?

The stty problem is not related to your environment, it's a result of the SSH command not allocating you a TTY ( What is Pseudo TTY-Allocation? (SSH and Github) ). Adding -t argument for ssh should fix it.

Further information:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM