In my script I need to access a remote server using ssh. On the remote I want to gather some data from log files. I have my script set up and the code works, but my problem is when I run the script it will get to the ssh and log onto the remote server, but it wont run the next command. It waits for a keyboard input but i need the command to run without an input from the keyboard.

This is what i have.

 value = `sshpass -p $PASSWORD ssh $USERNAME@$REMOTE_IP_ADDR | tail -F /tmp/file.txt | awk '{ print $16 }'`

//i have tested this line of code and it works how i need it to
 tail -F /tmp/file.txt | awk '{ print $16 }'
  • Try to remove the pipe between ADDR and tail and don't forget to read the man pages of ssh. – ctac_ Mar 4 '19 at 16:02

Issue was the pipe between the ADDR | tail

//old code
     value = `sshpass -p $PASSWORD ssh $USERNAME@$REMOTE_IP_ADDR | tail -F /tmp/file.txt | awk '{ print $16 }'`

//edited code (working)
 value = `sshpass -p $PASSWORD ssh $USERNAME@$REMOTE_IP_ADDR tail -F /tmp/file.txt | awk '{ print $16 }'

Thanks for the help ctac_

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.