bash - Exporting data from expect script -


so i've written short expect script logs apc power distribution unit interface via telnet , polls current ampage.

    #!/usr/bin/expect     set ip "192.168.0.1"     set username "myusername"     set password "mypassword"     spawn "/bin/bash"     send "telnet $ip\r"     expect "*user name*"     send "$username\r"     expect "*password*"     send "$password\r"     expect "*apc*"     send -- "phreading current\r"     expect "*success*"     send  "quit\r"     expect eof 

the script job , see amps on screen, displayed this:

    apc>phreading current     e000: success     1: 7.5     apc>quit 

what need 'export' 7.5 figure, either text file or pass bash script variable.

any ideas on how can this?

thank you!

expect extension of tcl, have access of tcl's constructs.

if have expect script write directly file.

see section "writing file" here: http://wiki.tcl.tk/367. has simple example that. in case, want open file append (a) instead of write (w).

open command documentation at: http://www.tcl.tk/man/tcl8.6/tclcmd/open.htm

let me know how works you.


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -