Skip to content
Advertisement

bash command redirection in expect script failing with permission denied (spawn ssh user@host command > outfile)

I have this expect script

JavaScript

that is supposed to read a gpg encrypted password, and use it to call a remote script via ssh (there are many reasons why I need to do it like that). Now, my problem is that whenever I run this script, the ssh connection is correctly set up, but it fails in writing the output of the ssh call with the error

JavaScript

I’m running the script as root (because I have to run it as root), and I already tried to change the permissions and ownerships of all the involved files and directories.

Advertisement

Answer

The redir char > is not special for expect’s spawn command. The command

JavaScript

means the same as

JavaScript

and the redir > outfile will be executed on the remote host.

Try like this:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement