0

I write the following simple script , the target of the following script is to copy info_file from target Linux (red hat 5.1) machine to my current Linux machine without entering login or password

I will happy to get some work examples with python that perform the same procedure as my expect script

  #!/bin/ksh

  rm -rf /root/.ssh/known_hosts

  expect_get_info_file=`cat << EOF
  set timeout -1
  spawn  ssh 100.16.10.15
  expect ?                {send yes\r} 
  expect password:        {send pass123\r}
  expect #                {send "scp -rp 100.16.10.15:/tmp/info_file /tmp\r"}
  expect password:        {send pass123\r}
  expect #                {send exit\r}
  expect eof
  EOF`


  expect -c  "$expect_get_info_file"
diana
  • 61

1 Answers1

0
import pexpect
child = pexpect.spawn("ssh ....")
child.expect("...")
child.send("...")
u1686_grawity
  • 452,512