1

I want to connect from ServerA to ServerB , and check Oracle Database Status and PendingLogs then record results, and use the result on ServerA ,and compare with the result on serverA and generate logs on serverA.

I used ssh -q root@192.168.11.131 sh -s < /root/script.sh > /root/output.txt

but I still have to enter password manually.

  1. is there any way to turn off interactive login?

  2. how can I run script file via spawn ssh?

0

1- is there any way to turn off interactive login?

Yes, use public key authentication or sshpass to enter password.

2- how can I run script file via spawn ssh ?

Yes, use expect script. If you want to run some other script inside (awk), you need to escape the special characters (\$).

  • Then you have the other two options described in my answer. – Jakuje Nov 28 '16 at 11:40
  • we are not authorize to use Public key Authentication , and sshpass -f /path/to/myfile ssh user@localhost is not working on CentOS. I used expect , but in my commands I have Awk and it doesn't support. – Reza Nov 28 '16 at 12:15
  • you need to specify why it does not work. Probably you just need to install it? In the expect, it should not matter. You use it only to connect to the server, not to run any other tools (awk). – Jakuje Nov 28 '16 at 12:17
  • 1
    you're right sshpass wasn't install. after installation sshpass problem solved. but we are not authorize to install and use this package. About AWK I found following format to use awk in expect. and it worked!! #set cmd "df -h | grep /dev/sda1 | exec awk '\{ print \$4\}'\r" send $cmd – Reza Nov 28 '16 at 13:09

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.