Thursday, December 20, 2007

Diagram Of Where Rotator Cuff Tear Is

Script to record what is done in a shell (ssh)


For my work I document actions executed in the client hosts with full fidelity. Some time ago I was looking for a tool type gnome-terminal (or virtual console) with the ability to save the log of all input / output inside this terminal. This functionality I would be very useful not only to perform the documentation that I offer, but also to quickly provide practical examples of execution of commands via terminal or log of some set of particular actions. At the moment I have not found any terminal that functionality (I have not made an exhaustive search), but if I found the proper application of bash script that allows something. Using a shell I've ever ridden, it automatically records all input / output which run through ssh, save the log to a default directory organized by hosts accessed. The name of the log file tells me that I did the ssh user and at what time. I leave here the script (in my examples is called fer_ssh2.sh) is useful in case you or if you can be with the changes that you believe appropriate. I also enclose a sample output of executions and the appearance of the log directory to serve as an example of what I had.

# / bin / bash
CHAIN \u200b\u200b= $ 1 = $ HOME/logs_ssh2 DIRBE
DATE = `date
+% Y% m% d-% H.% M.% S `
ELHOST = $ {string # * @} Elus = $ {STRING% @ *} DIRLOG = $ DIRBE / $ ELHOST if [-d $ DIRLOG] Then
# if we do nothing - TODO: see if we can deny if
echo "1"> / dev / null
# the directory exists, we LOG fi = $ DIRLOG / $ DATE-$ ELUSER.log echo "************************************
**************" echo "* MAKING ssh $ 1"
echo "* Saving log in $ LOG" echo "*************
*************************************" script-c "ssh-X $ 1" $ LOG exit








actual output terminal where fer_ssh2.sh launched (against my own host machine via name)





dballester @

Nebuchadnezzar: ~ $ fer_ssh2.sh dballester @ Nebuchadnezzar
***************************************
*********** * SSH AGAINST DOING dballester @ Nebuchadnezzar
* Saving log in / home/dballester/logs_ssh2/nebuchadnezzar/20071220-12.19.26-dballester.log
******* *******************************************
Script iniciado; el fichero es /home/dballester/logs_ssh2/nebuchadnezzar/20071220-12.19.26-dballester.log
The authenticity of host 'nebuchadnezzar (127.0.1.1)' can't be established.
RSA key fingerprint is af:6e:94:98:83:e1:d3:22:a9:c2:cf:d7:28:3a:59:c3.
Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'nebuchadnezzar' (RSA) to the list of known hosts.
  • dballester@nebuchadnezzar's password: Linux nebuchadnezzar 2.6.22-14-generic #1 SMP Sun Oct 14 23:05:12 GMT 2007 i686 The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in
  • the individual files in / usr / share / doc / * / copyright. Ubuntu

with ABSOLUTELY NO WARRANTY eat, to the Extent permitted by applicable law
. You Have mail.
Last login: Thu Dec 20 11:59:12 2007 from localhost
dballester @ Nebuchadnezzar: ~ $ hostname

dballester @ Nebuchadnezzar Nebuchadnezzar: ~ $ df-h
S.ficheros Size Used Avail Use% Mounted on
/ dev / sda6 4.6 G 3.9 G 536M 88% /
varrun 502m 502m 112K 1% / var / run
varlock 502m 0 502m 0% / var / lock udev
502m 502m 108K 1% / dev
devshm 502m 0 502m 0% / dev / shm
lrm 34M 502m 468m 7% / lib/modules/2.6.22-14-generic/volatile
/ dev / mapper / data-homes 30G 16G 13G
56% / home
/ dev/sda1 76M 41M 32M 57% / boot
/ dev/mapper/data-oracle11g
7.9 G 5.9 G 1.6 G 79% / u01
/ dev/scd0 G 7.6 7.6 G 0 100% / media/cdrom0
dballester @ Nebuchadnezzar: ~ $ exit

logout Connection closed to Nebuchadnezzar. Script
completed, the file is / home/dballester/logs_ssh2/nebuchadnezzar/20071220-12.19.26-dballester.log
dballester @ Nebuchadnezzar: ~ $







Actual output terminal where fer_ssh2.sh launched (against my own host via localhost)








dballester @ Nebuchadnezzar: ~ $ fer_ssh2.sh dballester @ localhost


********* *****************************************

* @ dballester DOING AGAINST SSH
localhost
    * Saving log in / home/dballester/logs_ssh2/localhost/20071220-12.21.35-dballester.log
  • ********************* *****************************

Script started, file is / home/dballester/logs_ssh2/localhost/20071220-12.21.35-dballester.log dballester @ localhost's password:
Nebuchadnezzar Linux 2.6.22-14-generic # 1 SMP Sun October 14 23:05:12 GMT 2007 i686

The Programs included with the Ubuntu system Are free software;
the exact distribution terms for Each program Are Described in the
individual files in / usr / share / doc / * / copyright. Ubuntu
with ABSOLUTELY NO WARRANTY eat, to the Extent permitted by applicable law
. You Have
mail.

Last login: Thu Dec 20 12:19:33 2007 from nebuchadnezzar
dballester@nebuchadnezzar:~$ ifconfig
SIOCGMIIPHY on 'eth3' failed: Operation not permitted
SIOCGMIIPHY on 'eth4' failed: Operation not permitted
SIOCGMIIPHY on 'eth5' failed: Operation not permitted
SIOCGMIIPHY on 'eth6' failed: Operation not permitted
SIOCGMIIPHY on 'eth7' failed: Operation not permitted
no MII interfaces found
dballester@nebuchadnezzar:~$ sudo mii-tool
[sudo] password for dballester:
eth0: no autonegotiation, 10baseT-HD, link ok
SIOCGMIIPHY on 'eth1' failed: Operation not supported
dballester @ Nebuchadnezzar: ~ $




looks log directories

dballester @ Nebuchadnezzar: ~ $ ls-lR logs_ssh2 logs_ssh2: total 36
drwxr-xr-x 2 4096 20/12/2007 12:23 dballester dballester localhost drwxr-xr-x 2 4096 20/12/2007 12:19 dballester dballester Nebuchadnezzar
logs_ssh2/localhost:
total 16-rw- r - r - 1 dballester dballester 4096 2007-12-20 12:22 20071220-12.21.35-dballester.log -rw-r - r - 1 131 20.12.2007 12:23 dballester dballester 20,071,220 -23.12.1910-dballester.log
logs_ssh2/nebuchadnezzar: total 4-rw-r - r - 1 dballester dballester 1795 2007-12-20 12:19 20071220-12.19.26-dballester.log
dballester @ Nebuchadnezzar: ~ $

0 comments:

Post a Comment