1

I am creating a Jenkins job in which am running a ssh command to execute a script for comparing two folders using diff command on a remote server. Script is running fine, output file is getting created. But after this command Jenkins execute shell block is failed.

Command:

ssh -T user@dtest.com "bash /tmp/sample.sh" >> result.txt

Log:

ssh -T user@dtest.com "bash /tmp/sample.sh" >> result.txt

stdin: is not a tty

"Execute shell" is marked as failure

Community
  • 1
  • 1
  • Are you sure the script is running properly? The file will be created regardless of how the script runs because you're using the standard stream redirection operator. – Vasan May 03 '18 at 06:27
  • What happens if you replace `-T` by `-t`? – user1934428 May 03 '18 at 08:50

1 Answers1

0

I am not sure what sample.sh is supposed to do, but I understand that you are trying to capture what is logged by this script.

I would try several solutions:

ssh -T user@dtest.com "bash /tmp/sample.sh >> result.txt"

This should save your output in your remote server. Then you could copy this file from remote to local using:

scp user@dtest.com:/remote/dir/result.txt /local/dir/

More context: Copying files from server to local computer using ssh

If you are choosing this solution, you could also consider to write your result.txt directly from your script, and keep the console output for important logging purpose.

Another Solution I could think of would be to use

ssh user@dtest.com "bash /tmp/sample.sh" > result.txt

With this solution you will redirect your output directly to your local machine. But you will need to delete the ssh "-T" option. And you will run into other problems with Jenkins. So this might not fit you.

ssh -T Disables pseudo-tty allocation, what sounds like your problem's root cause. (https://docs.oracle.com/cd/E36784_01/html/E36870/ssh-1.html)

Luc
  • 1,393
  • 1
  • 6
  • 14