Thursday, November 7, 2013

Script Command in UNIX for creating LOG files

 How to Use Script Command in UNIX:

:/root>script mylogfile.txt
Script started, file is mylogfile.txt
:/root>pwd
/root
:/root>cd SARAVANAN/
:/root/SARAVANAN>ls -lrt
total 20
drwxr-xr-x    5 root     root         4096 Mar 21  2013 SARAVANAN_RQ011305
drwxr-xr-x    4 root     root         4096 Apr 30  2013 65456A_T38
drwxr-xr-x    5 root     root         4096 Oct 15 06:13 SARAVANAN_RQ011308
drwxr-xr-x    3 root     root         4096 Nov  6 05:50 SARA_SIP_SIP_RQ011308
drwxr-xr-x    2 root     root         4096 Nov  8 04:24 3GPP_TEST
:/root/SARAVANAN>
:/root/SARAVANAN>
:/root/SARAVANAN>
:/root/SARAVANAN>exit
Script done, file is mylogfile.txt



mylogfile.txt in /root/ folder will contain the snapshot of all commands entered during the script is made ON/OFF

 :/root/vi mylogfile.txt
Script started on Fri Nov  8 04:56:04 2013
:/root>pwd^M
/root^M
:/root>cd A^H ^HSARAVANAN/^M
:/root/SARAVANAN>ls -lrt^M
total 20^M
drwxr-xr-x    5 root     root         4096 Mar 21  2013 SARAVANAN_RQ011305^M
drwxr-xr-x    4 root     root         4096 Apr 30  2013 65456A_T38^M
drwxr-xr-x    5 root     root         4096 Oct 15 06:13 SARAVANAN_RQ011308^M
drwxr-xr-x    3 root     root         4096 Nov  6 05:50 SARA_SIP_SIP_RQ011308^M
drwxr-xr-x    2 root     root         4096 Nov  8 04:24 3GPP_TEST^M
:/root/SARAVANAN>^M
:/root/SARAVANAN>^M
:/root/SARAVANAN>^M
:/root/SARAVANAN>exit^M

Script done on Fri Nov  8 04:56:21 2013




Note : Script captures every keystroke including Backspace, DELETE. (see cd SARAVANAN, ^H is for Backspace. The user had typed A instead of S. So he pressed backspace)

No comments:

Post a Comment