1753797 Members
8004 Online
108799 Solutions
New Discussion юеВ

Re: script command

 
SOLVED
Go to solution
Shivkumar
Super Advisor

script command

Hi,

I used $script abc.txt command to store the screen output of various commands.

But i saw various junk characters in the output. i think there are line feed, enter and other key strokes also which make screen output very difficult to understand.

Is there any trick to filter out this or use some way to avoid keystroke/linefeed etc in output file ?

Thanks,
Shiv
8 REPLIES 8
Patrick Wallek
Honored Contributor

Re: script command

If you are trying to use script to capture something like SAM, or some menu based application, then you are not going to have very good luck.

script is really just meant for basic command line capture, nothing fancy.
Yogeeraj_1
Honored Contributor

Re: script command

hi Shiv,

i agree with Patrick.

Something i find useful in case i am waiting for a particular command is use something similar to:

tail -f abc.txt | grep -i "command that i am waiting"

hope this helps!

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)
Yang Qin_1
Honored Contributor

Re: script command

You may try dos2ux abc.txt > def.txt

Yang
rariasn
Honored Contributor

Re: script command

Hi Shivkumar,

cat abc.txt|grep -vE "\[|\^"

rgs

Raj D.
Honored Contributor

Re: script command

Shiv,

script command will not only give you about the command history , but also it will give the output of the commands .
Also if any menu driven program used in the session it will log that too, and junk and control characters will fill in the log file . so be careful to have much space on that filesystem to log entire activity.



cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Raj D.
Honored Contributor

Re: script command

Shiv,

For example if u are using on that session:

$ ls -l

It will log 'ls -l' along with the output of it.

Secendly if you use 'sam' or 'glance' it will capture all the charcters with control characters.

Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Bill Hassell
Honored Contributor
Solution

Re: script command

You are seeing exactly what was sent to/from the connection. You can filter out the special codes (due to menus and special character enhancements) with something like:

cat -v abc.txt
or
tr -d ["\000-\011\013-\037"] abc.txt
or
tr -d ["\000-\011\013-\037\200-\377"] abc.txt

but to make it look nice, you have to decide what 'looks nice'. That's because it all depends on what you intend for this file. It won't look like the terminal unless it is played back on the same type of terminal.


Bill Hassell, sysadmin
vinod_25
Valued Contributor

Re: script command

Hi Shiv,

Use SED with the following options...

# ./script | sed 's/\x00//g' > abc.txt

Shiv you are so kind in assigning points...

Regards,
Vinod