tag:blogger.com,1999:blog-6216929280664088149.post2722059508141679853..comments2023-05-29T12:01:49.450+03:00Comments on Jibby George - UNIX and Virtualization Blog: Automating sftp with expect scriptJibby Georgehttp://www.blogger.com/profile/15273204429626583202noreply@blogger.comBlogger11125tag:blogger.com,1999:blog-6216929280664088149.post-70850230013346883092014-05-06T21:59:07.909+03:002014-05-06T21:59:07.909+03:00Hi
I have problem with file transmission (file 20...Hi<br /><br />I have problem with file transmission (file 200MB +/- 50MB).<br />The trasmission had been interrupted before finished dowloading. Rest works good. Any ideas ??Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6216929280664088149.post-28550776721556064142012-06-27T16:11:57.762+03:002012-06-27T16:11:57.762+03:00Worked great! Thank you!Worked great! Thank you!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6216929280664088149.post-33204195288024408602012-03-07T00:21:31.173+03:002012-03-07T00:21:31.173+03:00I have a simple requirement and try to figure out ...I have a simple requirement and try to figure out how to do it in EXPECT.<br /><br />after sftp into a server. I want to cd into the latest directory (Note $HOME has directories and files). Any idea a easy way to achieve this??<br /><br />ThanksJoehttps://www.blogger.com/profile/14483302823973532930noreply@blogger.comtag:blogger.com,1999:blog-6216929280664088149.post-18509120447441537832011-12-23T20:18:14.551+03:002011-12-23T20:18:14.551+03:00I was able to figure out my check for invalid or e...I was able to figure out my check for invalid or expired password. The system I was connecting to does not tell you if the password is invalid, it just gives the password prompt over and over that is why there is a second expect for the password prompt. I also put in a check for upper and lower case prompts. After doing the spawn of the sftp command it goes like this:<br /><br />spawn sftp mylogonid@someserver<br />expect -re "password|Password:"<br />send "mypasswd\r"<br /> expect -re "password|Password:" {<br /> puts "Password was not accepted \n"<br /> exit 2<br /> } -re "expired|Expired" {<br /> puts "Password Expired \n"<br /> exit 3<br /> } -re "invalid|Invalid" {<br /> puts "Password Invalid \n"<br /> exit 4<br /> } "sftp>" {<br /> send "pwd\r"<br /> expect "sftp>"<br /> send "put myfilename yourfilename\r" <br /> expect "sftp>"<br /> send "bye\r"<br /> }Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6216929280664088149.post-13221616087617033712011-12-23T00:52:58.873+03:002011-12-23T00:52:58.873+03:00How can I check to see if the password is invalid ...How can I check to see if the password is invalid or expired? I have a similar task to automate. Nice script.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6216929280664088149.post-64743043569018768452011-09-29T21:23:26.751+03:002011-09-29T21:23:26.751+03:00Hi Jibby, found a solution to get away with the $ ...Hi Jibby, found a solution to get away with the $ symbol using expect. When I place the \ (backward slash) in front of the $ symbol, then it works fine.<br /><br />Thanks!<br />NareshAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6216929280664088149.post-30702057372769415412011-09-29T02:26:01.594+03:002011-09-29T02:26:01.594+03:00Great! Thanks much for your help Jibby.
NareshGreat! Thanks much for your help Jibby.<br /><br />NareshAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6216929280664088149.post-71357954014846390302011-09-29T02:22:58.124+03:002011-09-29T02:22:58.124+03:00HI Naresh , thanks for that. Its been a while I wo...HI Naresh , thanks for that. Its been a while I worked with expect. There should be a way to do that. If I figure out something will post here.<br /><br />JibbyJibby Georgehttps://www.blogger.com/profile/15273204429626583202noreply@blogger.comtag:blogger.com,1999:blog-6216929280664088149.post-48789881627849636272011-09-29T01:44:44.013+03:002011-09-29T01:44:44.013+03:00Hi Jibby,
I have a similar requirement. Your metho...Hi Jibby,<br />I have a similar requirement. Your method of doing that is impressive. I tried to follow this. But, the glitch here is that the sftp user name has a special character $ in its name. While running the script the spawn/expect/send libraries are treating the text after $ symbol as a variable. Is there a way that you think of to get away with that. I tried single quotes, double quotes around the user name but no luck.<br /><br />Thanks for your help.<br /><br />NareshAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6216929280664088149.post-84938256490381747962011-08-25T11:09:44.719+03:002011-08-25T11:09:44.719+03:00Gald that it helps youGald that it helps youJibby Georgehttps://www.blogger.com/profile/15273204429626583202noreply@blogger.comtag:blogger.com,1999:blog-6216929280664088149.post-30089530762821070192011-07-19T13:12:20.993+03:002011-07-19T13:12:20.993+03:00Hi Jibby George,
Thanks a lot for posting this.
...Hi Jibby George,<br /><br />Thanks a lot for posting this. <br />I was really fed up googling this, but finally stick to your site and works perfectly. <br /><br />Thankyou Man. you are so special. you made it so easy. <br /><br />ThankYouDevenhttp://pawars.innoreply@blogger.com