Pass argument to bash script with expect and SSH -


i trying write remote control script can grep key words when tailing.

$ ./myscript.sh somekeyword 

i expect log on remote machine , run

$ tail -f /tmp/log/mylog.log | grep "somekeyword" 

here code:

#!/usr/bin/expect eval spawn ssh -ostricthostkeychecking=no -ocheckhostip=no root@myhost #use correct prompt set prompt ":|#|\\\$" interact -o -nobuffer -re $prompt return send "mypassowrd\r" interact -o -nobuffer -re $prompt return send "tail -f \/tmp\/log\/mylog.log | grep \"$1\"\r" interact 

can me?

thanks in advance!

instead of passing simulating interactive session would:

  • setup ssh key based authentication - removes need of entering password
  • then use:

    ssh root@kroute "logread \| grep asd"


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -