Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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