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"
link|improve this question

20% accept rate
2  
Please don't. There are much easier and more secure ways of doing automatic SSH logins than that. – grawity Nov 16 '11 at 8:07
sorry I dont have expect tool to auto ssh , so the final option is python – diana Nov 17 '11 at 21:26
You just completely ignored what I said, didn't you. – grawity Nov 17 '11 at 22:03
no I am not , I know the ssh and public keys proccess , but I cant use this , sorry ( because some internal ishhues , ) , – diana Nov 18 '11 at 7:45
feedback

1 Answer

import pexpect
child = pexpect.spawn("ssh ....")
child.expect("...")
child.send("...")
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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