Jump to content
xisto Community
Sign in to follow this  
mizako

Expect and Tcl About expect and Tcl

Recommended Posts

Hi,
I am quite new in Xisto and i do not know if i am supposed to open new topics. If not please let me know.

I am using normally Perl at work but now i need to use expect. Expect is a language that allows you to interact with prompts such telnet, ftp and staff like that. I have to interact with some consoles simultaneosly and send both of them commands.

Expect uses tcl. I am really new with tcl. I need to open a file and read line by line in order to send those line to a console. Maybe anyone can help me with this basic operation. I think i have to use the exp_open command. In Perl would be something like this:

[/br]open <INPUT>, FileName[br]    or die "Can't open FileName for reading;[/br]while ( <INPUT> )[br]{[/br]print "$_"; #Operation with the line. I should make more complicated things;-)[br]}[/br]

Share this post


Link to post
Share on other sites

Hi,
I create a simple Expect script to automate my ftp login into my trap account. I made my ftp uploads running the ftp command in linux so i created this script to save me time in typing my Login and password. It logins for you and returns you the control.
I hope it is useful for you guys. Remember just install expect and enjoy it:

[br][/br]set host your_name.trap17.com[br]set Login your_name[/br]set Passwd your_password[br][/br]spawn ftp $host[br]expect "Name (*):"[/br]send "$Login\r"[br]expect "Password:"[/br]send "$Passwd\r"[br]expect {[/br]    "ftp>" { interact }[br]    "Login failed." { exit 1 }[/br]    timeout { exit }    }[br][/br]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.