Output is not clear
Posted by sanpraka (sanpraka), 1 April 2006hi experts,
i am new to expect.when i logged into the remote device and executed the command in ls -l.the output is captured in a file but there are some special characters in between the lines.can u please help me out in eliminating these characters from this ouput.
This is my script:
set filename "/tmp/logfile.txt"
set fileid [open $filename "w"]
set force_conservative 1
set match_max 100000
set timeout -1
set TASK "$argv\r"
set USER [lindex $TASK 1]
set SERVER [lindex $TASK 0]
set PASSWD [lindex $TASK 2]
spawn ssh $SERVER -l $USER
expect "email@example.com's password:"
send "ls -l\r"
set tempvar $expect_out(buffer)
puts $fileid $tempvar;
Here is the Sample output:
-rw------- 1 root root 798 Mar 17 17:05 ^[[00manaconda-ks.cfg^[[00m^M
-rw-r--r-- 1 root root 37 Mar 17 17:12 ^[[00mbirthdate^[[00m^M
drwxr-xr-x 2 root root 4096 Mar 20 16:36 ^[[00;34mDesktop^[[00m^M
-rw-r--r-- 1 root root 71590 Mar 17 17:05 ^[[00minstall.log^[[00m^M
-rw-r--r-- 1 root root 9737 Mar 17 17:05 ^[[00minstall.log.syslog^[[00m^M^[[m^0;root@localhost:~^G[root@localhost ~]#
Please help me out by gving a fast reply.i will be very much thankful.
Posted by admin (Graham Ellis), 1 April 2006The extra characters are a terminal control sequence that's sent out by your remote host to provide formatting. If you set the terminal type for your session to DUMB, you should be able to prevent the problem. Do so via the login's .bashrc file or via an export command that's a part of your sequence if you're using the bash shell ... the commands / files vary a bit for other shells.
Sanjeev, welcome to Opentalk. You write "Please help me out by gving a fast reply" I have a target of making technical comment (at least) on 90% of questions within 24 hours, and I always get back quicker if I can. I prioritise questions raised by people who give (i.e. help answering questions) as well as take, and questions raised by people I have trained (for whom the service was created in the first place). If you are not in one of these groups and require a faster support service, you can buy it; have a look here for example - "Entry P4" lists a contract at $2500 per annum with 24 hour emergency support available on an additional time and materials basis. However, that is not something I can provide.
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: firstname.lastname@example.org • WEB: http://www.wellho.net • SKYPE: wellho