From: Bruce Meyer on 20 Jan 2010 14:25 I have tried this several ways. Apprarently I am just doing something very basic incorrectly. I need to upload an updated iso once a week. I want to remove the old iso, before uploading the new iso. I have tried spawning ssh and remove this file as: #!/usr/bin/expect set timeout -1 spawn ssh username(a)host.mydomain.com expect "password:" send "password\r" expect username(a)host:~# send rm /path/to/file/filename.iso\r\n I have tried using : exec rm -f /path/to/file/filename.iso I have tried using sftp: #!/usr/bin/expect spawn $env(SHELL) log_file -noappend typescript spawn sftp username(a)host.mydomain.com expect "password:" send "password\n" expect "sftp> send "cd /path/to/file/\n" expect "sftp> send "rm filename.iso\n" expect "sftp>" send "mput /Users/bdmeyer/somefilename\n" expect "sftp> " send "exit\n" The only thing that really seems to work ok is connecting and authenticating. Does anyone have any idea what I might be messing up? --Bruce D. Meyer
From: Bruce Meyer on 21 Jan 2010 13:21 I just replaced the direct send "commands\r" with variables and they work now.
From: Glenn Jackman on 21 Jan 2010 14:34 At 2010-01-20 02:25PM, "Bruce Meyer" wrote: > I have tried this several ways. Apprarently I am just doing something > very basic incorrectly. > I need to upload an updated iso once a week. > I want to remove the old iso, before uploading the new iso. > > I have tried spawning ssh and remove this file as: > > #!/usr/bin/expect > set timeout -1 > spawn ssh username(a)host.mydomain.com > expect "password:" > send "password\r" > expect username(a)host:~# > send ?rm /path/to/file/filename.iso\r\n? You might want to investigate using ssh keys to login without requiring a password, and then you don't need expect at all: ssh user(a)host rm /path/to/file When you're developing an expect script, do: exp_internal 1 so you can see what's going on under the hood. -- Glenn Jackman Write a wise saying and your name will live forever. -- Anonymous
From: Hai Vu on 25 Jan 2010 13:57 Glenn Jackman was right on the money: Setting up public key authentication will greatly simplify your workflow. I learned to setup my system from this page: http://www.webmonkey.com/tutorial/Automate_a_Remote_Login_Using_SSH-Agent The instruction here is among the simplest I found.
|
Pages: 1 Prev: Graph Algorithms Next: TclOO: my varname does not work with arrays? |