[ale] [OT] expect script question
Ed Cashin
ecashin at noserose.net
Thu Apr 5 20:13:01 EDT 2012
Hi. I like expect. Have you already checked out some online tutorials?
The example below shows a couple of features I like for the kind of thing
you're doing. You'll need spawn, too.
ecashin at Ed-Cashins-MacBook-Pro tmps$ ~/tmp/exp-eg
username: hallandoats
hallandoats
ecashin at Ed-Cashins-MacBook-Pro tmps$ cat ~/tmp/exp-eg
#! /usr/bin/expect
send "username: "
expect -re "(.*)\n"
set user $expect_out(1,string)
send "$user\n"
ecashin at Ed-Cashins-MacBook-Pro tmps$
On Thu, Apr 5, 2012 at 7:41 PM, Robert Heaven <roberth1954 at aim.com> wrote:
> I need to write an expect script to ssh to a host, do a cd to a dir, do an
> ls to list some file and then do chmod on certain files. I know that
> executing the "cd" and "ls" commands would use a simple "send" but, how do
> I capture the output of the "ls" and how do I loop through the list so that
> I can "send" the chmod command. I know how to do all these things in bash
> and perl, I'm just not familiar with tcl/tk.
>
> -Robert
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://mail.ale.org/mailman/listinfo/ale
> See JOBS, ANNOUNCE and SCHOOLS lists at
> http://mail.ale.org/mailman/listinfo
>
--
Ed Cashin <ecashin at noserose.net>
http://noserose.net/e/
http://www.coraid.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.ale.org/pipermail/ale/attachments/20120405/86c6c218/attachment.html
More information about the Ale
mailing list