• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 195

Backtrace:

File: /home/u125378470/domains/lawhelpguru.org/public_html/application/views/question.php
Line: 195
Function: _error_handler

File: /home/u125378470/domains/lawhelpguru.org/public_html/application/controllers/Questions.php
Line: 416
Function: view

File: /home/u125378470/domains/lawhelpguru.org/public_html/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Bash script to detect last command runned in terminal

I have to make a script that print all commands used by user. So I try to make a script that will run in background and which delete history and register every command runned from that moment and echo it in a file. This is what i make but dont work.

function add_new_command() {
    nr=$(history | wc -l)
    
    if [ $nr -eq 1 ]; then 
        comanda=$(history | head -n 1)
        echo $comanda > mycommands
        history -c
    fi
}

history -c
while true
do
add_new_command
done