ssh in korn script gives 'stty: tcgetattr: A specified file does not support the ioctl system call.'

StackOverflow https://stackoverflow.com/questions/21943432

  •  14-10-2022
  •  | 
  •  

Question

I have a command that works successfully when executing via a putty window connected to an AIX box.

ssh -T user@host 'sudo /path/to/command argument1'

However, when I build that command in a script based on asking for user and host, it gives me this error.

ksh: sudo /path/to/command argument1:  not found.

I have my script set to output its commands as it runs.

#!/bin/ksh -x

This is the text in the script that ultimately gives the output above -

ssh -T $(whoami)@$server "'"$userid $script$action"'"

And this is what outputs from that script text (its identical to calling it outside script) -

ssh -T user@host 'sudo /path/to/command argument1'

Is there some difference in the way this is executing?

Update:

I changed my script to just connect without executing and I get the following error, but it still connects. -

ssh -T user@host
user@host's password:
stty: tcgetattr: A specified file does not support the ioctl system call.
#
Was it helpful?

Solution

wrap your command to run on the remote server in double quotes:

ssh -T $(whoami)@$server "$userid $script$action"

More info from the AIX site

OTHER TIPS

I was able to figure this out, although I would love an explanation. Removing the single quotes from the script made it work.

Works from script and outside script:

ssh -T $(whoami)@$server $userid $script$action

Doesn't work for script, but works outside script:

ssh -T $(whoami)@$server "'"$userid $script$action"'"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top