Script Output coming in wrong format....


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script Output coming in wrong format....
# 1  
Old 04-28-2015
Script Output coming in wrong format....

Hi team,
getting output logs wrong in different format from telnet script ...


getting Output.txt

Code:
[33m19.[0m [34mU-UU-LVDT-NODE-6006[0m [[33mNODE_3233[0m]            macro_outdoor_dist-6.0.0(v4_0_2)                DN:1.3.903 (1101:100:11w:500:3:2:103:aa)       
[33m20.[0m [31mU-UU-LVDT-NOD-6009[0m [[33mNOD_3163[0m]            macro_outdoor_dist-8.1.0(v3_1_0)                DN:1.3.409 (N/A)       
[33m21.[0m [31mU-UU-LVDT-NOD-6010[0m [[33mNOD_3167[0m]            macro_outdoor_dist-7.1.0(v3_1_0)                DN:1.3.424 (N/A)       
[33m22.[0m [31mU-UU-LVDT-NOD-6011[0m [[33mNOD_4454[0m]            macro_outdoor_dist-6.0.0(v4_0_2)                DN:1.3.398 (1101:100:11e:300:3:2:103:dd)       
[33m23.[0m [31mU-UU-LVDT-NOD-6012[0m [[33mNOD_3180[0m]            macro_outdoor_dist-6.1.0(v3_1_0)                DN:1.3.420 (N/A)       
[33m24.[0m [31mU-UU-LVDT-NOD-9011[0m [[33mNOD_2132[0m]            macro_outdoor_dist-6.1.0(v3_1_0)                DN:1.3.388 (N/A)       
[33m25.[0m [31mU-UU-LVDT-NOD-9013[0m [[33mNOD_2114[0m]            macro_outdoor_dist-6.1.0(v3_1_0)                DN:1.3.389 (N/A)       
[33m26.[0m [34mU-UU-LVDT-NOD-6000[0m [[33mNOD_2891[0m]            macro_outdoor_dist-6.0.0(v4_0_2)                DN:1.3.724 (1101:100:11a:300:3:2:103:aa)


When run command manually its give right output like this but by using script output come diffrent
Right Output.txt is

Eg...
Code:
413. U-UU-LVDT-NOD-6002 [NOD_4406]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.494 (1234:333:aaa:2333:3:2:333:a)       
414. U-UU-LVDT-NOD-6004 [NOD_3805]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.589 (1234:333:aaa:2333:3:2:333:e)       
415. U-UU-LVDT-NOD-6005 [NOD_4288]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.349 (1234:333:aaa:1400:3:2:333:1e)      
416. U-UU-LVDT-NOD-6006 [NOD_2810]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.352 (1234:333:aaa:a00:3:2:333:7a)       
417. U-UU-LVDT-NOD-6008 [NOD_2803]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.613 (1234:333:aaa:a00:3:2:333:66)       
418. U-UU-LVDT-NOD-9006 [NOD_2320]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.618 (1234:333:aaa:1400:3:2:333:22)      
419. U-UU-LVDT-NOD-9014 [NOD_2095]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.347 (1234:333:aaa:a00:3:2:333:d6)


Using Following Script telnet.sh...
call it

Code:
telnet.sh >Output.txt

telnet .sh
Code:
#!/usr/bin/expect
set timeout 2
set ip [lindex $argv 0]
spawn telnet $ip
expect "login:"
send "(username)\r"
expect "Password:"
send "(password)\r"
sleep 2
send "(my commands)\r"
expect eof
exit

Moderator's Comments:
Mod Comment For at least the 5th time: Please use CODE tags (not ICODE tags) when marking long lines and when marking multi-line input, output, and code segments.

Last edited by Don Cragun; 04-28-2015 at 03:03 AM.. Reason: Fix tags.
# 2  
Old 04-28-2015
So - what exactly is your question? I couldn't guess it even in your recent post...
# 3  
Old 04-28-2015
When I run script telnet.sh

Output.txt
getting like this..
Code:
[33m19.[0m [34mU-UU-LVDT-NODE-6006[0m [[33mNODE_3233[0m]            macro_outdoor_dist-6.0.0(v4_0_2)                DN:1.3.903 (1101:100:11w:500:3:2:103:aa)       
[33m20.[0m [31mU-UU-LVDT-NOD-6009[0m [[33mNOD_3163[0m]            macro_outdoor_dist-8.1.0(v3_1_0)                DN:1.3.409 (N/A)       
[33m21.[0m [31mU-UU-LVDT-NOD-6010[0m [[33mNOD_3167[0m]            macro_outdoor_dist-7.1.0(v3_1_0)                DN:1.3.424 (N/A)       
[33m22.[0m [31mU-UU-LVDT-NOD-6011[0m [[33mNOD_4454[0m]            macro_outdoor_dist-6.0.0(v4_0_2)                DN:1.3.398 (1101:100:11e:300:3:2:103:dd)       
[33m23.[0m [31mU-UU-LVDT-NOD-6012[0m [[33mNOD_3180[0m]            macro_outdoor_dist-6.1.0(v3_1_0)                DN:1.3.420 (N/A)       
[33m24.[0m [31mU-UU-LVDT-NOD-9011[0m [[33mNOD_2132[0m]            macro_outdoor_dist-6.1.0(v3_1_0)                DN:1.3.388 (N/A)       
[33m25.[0m [31mU-UU-LVDT-NOD-9013[0m [[33mNOD_2114[0m]            macro_outdoor_dist-6.1.0(v3_1_0)                DN:1.3.389 (N/A)       
[33m26.[0m [34mU-UU-LVDT-NOD-6000[0m [[33mNOD_2891[0m]            macro_outdoor_dist-6.0.0(v4_0_2)                DN:1.3.724 (1101:100:11a:300:3:2:103:aa)


But by directly run CMD on NODE getting
CMD output like this...
Code:
413. U-UU-LVDT-NOD-6002 [NOD_4406]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.494 (1234:333:aaa:2333:3:2:333:a)       
414. U-UU-LVDT-NOD-6004 [NOD_3805]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.589 (1234:333:aaa:2333:3:2:333:e)       
415. U-UU-LVDT-NOD-6005 [NOD_4288]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.349 (1234:333:aaa:1400:3:2:333:1e)      
416. U-UU-LVDT-NOD-6006 [NOD_2810]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.352 (1234:333:aaa:a00:3:2:333:7a)       
417. U-UU-LVDT-NOD-6008 [NOD_2803]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.613 (1234:333:aaa:a00:3:2:333:66)       
418. U-UU-LVDT-NOD-9006 [NOD_2320]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.618 (1234:333:aaa:1400:3:2:333:22)      
419. U-UU-LVDT-NOD-9014 [NOD_2095]           macro_outcome_dist-8.0.0(v1_0_2)                KK:1.2.347 (1234:333:aaa:a00:3:2:333:d6)


Why I'm getting different output by script??

Moderator's Comments:
Mod Comment For at least the 6th time: Please use CODE tags (not ICODE tags) when marking long lines and when marking multi-line input, output, and code segments.

Last edited by rbatte1; 04-29-2015 at 06:15 AM.. Reason: Changed ICODE tags to CODE tags
# 4  
Old 04-28-2015
Possibly because one is going to a terminal (capable of interpreting console codes for e.g. colour) and the other to a file.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Top Command Output is not coming via Cronjob

Dear All, I created a small script to get the CPU, GIS usage etc automatically. However when i run this script manually its working , but when i run through cronjob i am not getting any output. Can anyone please help me on this. I am using SuseLinux. Thank you in advance. #!/bin/sh {... (2 Replies)
Discussion started by: Nitin Kapoor
2 Replies

2. Shell Programming and Scripting

Output not coming as desired.

Hi guys. I have a file containing some hosts and their IPs. host host1 192.168.2.10 host host2 192.168.2.11 host host3 192.168.2.12 I am writing a script where I want to print these values in 1 line. My script looks like RUNTIME_NODE=`cat hosts.properties | grep host` for i in... (7 Replies)
Discussion started by: Junaid Subhani
7 Replies

3. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

4. Shell Programming and Scripting

awk Script to format output

Hi all, I'm fairly new to this and learning along the way, so bare with me... I'm trying to format the output from a script to be more read-friendly. The output contains more servers and more processes but for as example it will do: Server: Test1 ... (4 Replies)
Discussion started by: Bobsonm
4 Replies

5. Shell Programming and Scripting

Executing perl script in Linux gives :Exec format error. Wrong Architecture

i have perl script that used to be working great , once i edit it in windows and convert it to UTF-8 and then via FTP return it . also did: chmod +x foo.pl and then when i try to run it : ./foo.pl im getting this error: ./foo.pl: Exec format error. Wrong Architecture.... (4 Replies)
Discussion started by: umen
4 Replies

6. Shell Programming and Scripting

Output not in correct format - cd script

I have a script that looks like this: dirname2=/usr/tmp/filelist/*/* for dirname2 in /tmp/filelist/*/*; do (cd $dirname2/catalog ||echo "file does not exist" && echo "$dirname2" |cut -d '/' -f 7,8 && echo $i && ls -la |awk 'NR>3 {SUM += $5} END { print "Total number of kb " SUM }');done... (2 Replies)
Discussion started by: newbie2010
2 Replies

7. Shell Programming and Scripting

KSH Output not coming correctly !!!

Guys, I need some help, the output for my script below is causing me some issues.... Not sure where i am going wrong.. The out put should be all one line, but from some reasons its coming out on 4 lines... Can you suggesst what i am doing wrong please!!!!!! for MEDIA in `cat... (6 Replies)
Discussion started by: Junes
6 Replies

8. Shell Programming and Scripting

wrong output in perl script

Hi, Here is my piece of code-- #!/usr/bin/perl my $Time_Stamp ; my $User_Name; my $Success; my $Failure; my $ErrorCode; my $ErrorMsg; my $logDir = $ARGV; my $logPrefix = $ARGV; die "usage: $0 <logDir> <logPrefix>" unless $logDir and $logPrefix; die "Log dir $logDir doesn't... (2 Replies)
Discussion started by: namishtiwari
2 Replies

9. Shell Programming and Scripting

Script output format

Hi Gurus, 1. I have a script to run a SQL report. The script ran fine, but the format of the output is not satisfactory in that I see too much white space in between the lines in the output file (logfile). Please see the example below: 010192S.CD 01117CV000A.CD ... (6 Replies)
Discussion started by: syang68
6 Replies

10. Shell Programming and Scripting

Format output using awk in script.

Guys, I have a script which hits the database and pulls the information that I need into files. Now I want to format these files to make them easy to read. The sample format of the file will be like.... <Start_of_File> Header1 .....xsdfsfa...adfa...... Header2 ....afefas .aefaefsdf...... (8 Replies)
Discussion started by: bperl
8 Replies
Login or Register to Ask a Question