0

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?

d3pd
  • 7,935
  • 24
  • 76
  • 127
  • Syntax errors? If that's true, then you don't even have the right version of `bash` installed on the remote host. – chepner Nov 25 '15 at 21:08
  • @chepner No, the Bash version on the remote computer is identical. I've actually tried this with multiple machines, all of which have the same setup (and which are on AFS) and the behaviour is the same for all of them. – d3pd Nov 25 '15 at 21:11
  • Not all errors are syntax errors; I very much doubt you are getting any of those. – chepner Nov 25 '15 at 21:12
  • @chepner Following the [suggestion](http://stackoverflow.com/a/33926387/1556092) of Koterpillar, the syntax errors vanished with the use of `-t`. – d3pd Nov 25 '15 at 21:30
  • 1
    Those aren't syntax errors then. – chepner Nov 25 '15 at 21:30
  • @chepner What does the message `(standard_in) 1: syntax error` mean? It is an example of one error that vanished with the use of `-t`. – d3pd Nov 25 '15 at 21:32
  • We'd need to see `script.sh`, for all I know it could check for a TTY and then do an `echo syntax error`. – Koterpillar Nov 26 '15 at 08:45

1 Answers1

4

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:

Community
  • 1
  • 1
Koterpillar
  • 7,883
  • 2
  • 25
  • 41