Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Wed 19 Jun 2013, 09:40
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
howto capture the history of the inittab consoles ?
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [4 Posts]  
Author Message
Karl Godt


Joined: 20 Jun 2010
Posts: 2732
Location: Kiel,Germany

PostPosted: Tue 31 Jan 2012, 12:51    Post subject:  howto capture the history of the inittab consoles ?  

Hello !

I want at shutdown to write the history of each enabled console to the .history file .

I have constructed a rc.shutdown.local that gets sourced by rc.shutdown at the beginning >

Code:
currentconsole=`tty`
echo "currentconsole='$currentconsole'"
curr="$currentconsole";c=0
if [ "$curr" != '/dev/tty1' ];then chvt 1;fi
cons=`grep -oe '^tty[0-9]*' /etc/inittab`
CONS=`echo "$cons" | grep -o '[0-9]'`
maxcons=`echo $CONS|rev|sed 's/^[[:blank:]]*//'|cut -f 2-99 -d ' '|rev`
for con in $maxcons ; do c=$((con+1));chvt $c
#echo "`history|awk '{print $2}'`" >> .bash_history
#echo "`history|awk '{print $2}'`" >> .ash_history
echo -en "\r" >/dev/tty$c
echo -e "\n" >/dev/console
tty >>/dev/tty$c
echo $c >>/dev/tty$c
echo >>/dev/tty$c
read -e -n1 -p "History Rescue, hit [2x] any key " k 1>/dev/tty$c 2>&1 </dev/tty$c
#echo "`history|awk '{print $2}'`" >> .history
echo $k
echo $k >>/dev/tty$c
history -w
sleep 1s;
echo >>/dev/tty$c
read -e -n1 -p "Console Switch, hit [2x] any key " l 1>/dev/tty$c 2>&1 </dev/tty$c
echo $l
echo $l >>/dev/tty$c
echo "Sleeping now 5 seconds....." >>/dev/tty$c
sleep 5s
#[ "$c" -gt '2' ] && deallocvt $((c-1));
done
#deallocvt $c
chvt 1

#echo "`history|awk '{print $2}'`" >> .bash_history
#echo "`history|awk '{print $2}'`" >> .ash_history
#echo "`history|awk '{print $2}'`" >> .history
history -w


First of all i want to know why i have to type 2x key to get anything to work despite the waiting for command input of the particular console .

As a side note: deallocvt does not work for consoles opened by /etc/inittab .
Back to top
View user's profile Send private message Visit poster's website 
Karl Godt


Joined: 20 Jun 2010
Posts: 2732
Location: Kiel,Germany

PostPosted: Thu 15 Mar 2012, 23:55    Post subject:  

apparently i have found a solution : kill -1 `pidof sh`
automatically writes to the history file .
since the inittab respawns these consoles get opened again .
this works for all opened consoles , except the current one .
killing that console would also stop poweroff OR reboot .

Code:
currentconsole=`tty`
echo "currentconsole='$currentconsole'"
curr="${currentconsole//\/dev\//}"

CONS=`ps -f -C sh |grep tty|grep -vw "$curr" |awk '{print $2}'`
for pid in $CONS;do
kill -1 $pid
sleep 1s;sync
done
Back to top
View user's profile Send private message Visit poster's website 
disciple

Joined: 20 May 2006
Posts: 6199
Location: Auckland, New Zealand

PostPosted: Fri 16 Mar 2012, 20:01    Post subject:  

Is this about the history of which commands you run in the consoles, or the output of those commands?
_________________
DEATH TO SPREADSHEETS
- - -
Classic Puppy quotes
- - -
Beware the demented serfers!
Back to top
View user's profile Send private message 
Karl Godt


Joined: 20 Jun 2010
Posts: 2732
Location: Kiel,Germany

PostPosted: Sat 17 Mar 2012, 08:23    Post subject:  

Its about the commands .

But if I accidentally copy the output of a X-term console and paste it into it instead of a text editor , the console would try to run the new copied input with a lot of "command not found" messages .

Then i would have (parts of) the console output in the .[[b]ash_]history file .

The simple no-X console writes to .history as far as i experienced .
Back to top
View user's profile Send private message Visit poster's website 
Display posts from previous:   Sort by:   
Page 1 of 1 [4 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0559s ][ Queries: 11 (0.0110s) ][ GZIP on ]