Find the answer to your Linux question:
Results 1 to 2 of 2
Hi, I have automated SCP on my machine using the following: #!/usr/local/bin/expect -f set timeout 3000 set match_max 5000 spawn scp /home/username/test/test.txt username\@192.1.1.2:/home/userrname/ expect "username@192.1.1.2's password:" send "password\r" expect \">\" ...
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Posts
    3

    Exclamation Expect Help

    Hi,

    I have automated SCP on my machine using the following:

    #!/usr/local/bin/expect -f
    set timeout 3000
    set match_max 5000
    spawn scp /home/username/test/test.txt username\@192.1.1.2:/home/userrname/
    expect "username@192.1.1.2's password:"
    send "password\r"
    expect \">\"
    exit

    Right now it sends the test text file fine, how do i add in a function within this script in which it searches for a file name of a particular name and then SCP it?

    I know Expect is kinda similiar to Tcl, but how do i implement something like this?

    Thanks!

  2. #2
    Just Joined!
    Join Date
    Feb 2009
    Posts
    4
    If you are going to another nix type system you can user sftp.


    Code:
    #!/usr/local/bin/expect -f
    set timeout 3000
    set match_max 5000
    spawn sftp username@192.1.1.2 
    /userrname/
    expect ":"
    send "password\r"
    expect \">\"
    send "cd\r"
    expect \">\"
    send "dir\r"
    exit

    That should get you going in the right direction. You will also have to do the put command. To place your file out there.


    I have done most of my expect in a tcl environment and it seems to have a lot more flexibility.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...