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 \">\"
...
- 02-17-2009 #1Just Joined!
- Join Date
- Feb 2009
- Posts
- 3
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!
- 02-17-2009 #2Just 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.


Reply With Quote