open lxterminal -> execude command -> not in history

LXTerminal is the standard terminal emulator of LXDE - http://wiki.lxde.org/en/LXTerminal
Post Reply
holzbein
Posts: 2
Joined: Thu Apr 29, 2021 7:40 am

open lxterminal -> execude command -> not in history

Post by holzbein »

Hello!

I would likt to
  • open a new lxterminal window.
    call/execute a script in it (terminal keeps open)
    see this script call command in the bash.history

Code: Select all

lxterminal -e "/home/andi/Scripts/run_cmd.sh '/home/andi/Scripts/run_cmd.sh'; bash"
I tried by this "run_cmd.s"h script to
  • list the history,
    add the command to bash.history (history -s $1)
    list history.

Code: Select all

#!/bin/bash
echo parameter $1
echo aaaaaaaaaaaaaa
history
echo bbbbbbbbbbbbbbbb
history -s $1
echo cccccccccccccccccc
history
echo xxxxxxxxxxxxx
But the history is
  • empty
    has one entry
Then comes up the commandline in this lxterminal window. A "history" command then shows the full bash.history, but not th initial call command of this terminalwindow.

How can I solve this problem?
Thank you.

drooly
Posts: 744
Joined: Mon Apr 08, 2013 6:45 am

Re: open lxterminal -> execude command -> not in history

Post by drooly »

Let's clarify one thing:
This has nothing to do with lxterminal or LXDE, and everything with how your shell is set up.

That said, you do seem to have a valid problem there.
May I ask for some information first:
What distro? How did you install it, and which specific version? Have you made any (significant) changes?
Can you reproduce the problem with other terminal emulators (maybe xterm is already installed)?

Then, open a terminal, enter the following commands, and show us the output:

Code: Select all

echo $SHELL
set | grep HIST
env | grep HIST
ls -l ~/.bash*
cat ~/.bash_history
The last command might contain sensitive data, feel free to edit or omit.

holzbein
Posts: 2
Joined: Thu Apr 29, 2021 7:40 am

Re: open lxterminal -> execude command -> not in history

Post by holzbein »

drooly wrote:
Fri Apr 30, 2021 4:32 am
Let's clarify one thing:
This has nothing to do with lxterminal or LXDE, and everything with how your shell is set up.
Thank you!
OK, I se

I think the problem is, in my case - (lxterminal I see that other terminals may behave similar) - seems to execute the script, in the parameter given,
and then loads the history? and then shows the commandline in the lxterminal window.
On this commandline I get the full history - without the (last) script executed when opening the lxterminal.

Why is this a problem for me?

I would like to call the script, given as parameter by opening the lxterminal, by using the arrow key, as the last given command.

I use Lubuntu. Version? I don't know, sorry, I'm not so familiar with the linux interna, I'm just using it. ;)

The history stuff you asked for, looks normal and it works everywhere perfekt, even in this lxterminal window after the executing of the script)

Code: Select all

>:~$ set | grep HIST
HISTCONTROL=ignoreboth
HISTFILE=/home/a/.bash_history
HISTFILESIZE=2000
HISTSIZE=1000
>:~$ env | grep HIST
>:~$ ls -l ~/.bash*
-rw------- 1 a b 69655 Apr 29 20:18 /home/a/.bash_history
-rw-r--r-- 1 a b   220 Feb 28  2018 /home/a/.bash_logout
-rw-r--r-- 1 a b  3871 Apr 29 09:10 /home/a/.bashrc
thank you

drooly
Posts: 744
Joined: Mon Apr 08, 2013 6:45 am

Re: open lxterminal -> execude command -> not in history

Post by drooly »

^ Yes it looks normal.
I'm alittle confused now; are you saying you wrote a script that does not work as expected?
Show us the script?
Is this how you're executing it:

Code: Select all

lxterminal -e "/home/andi/Scripts/run_cmd.sh '/home/andi/Scripts/run_cmd.sh'; bash"
???
That might pose some problems wrt history:
  • bash might not update the history file when a command is executed from lxterminal's "-e" option.
  • the shell closes when the script finsihes, and you immediately open a new one - again, it's possible this has some effect on history updating
Why are you calling the script with its own path as an argument?

But really, I suspect some sort of X-Y-problem here - what are you really trying to achieve? What is this script doing, why do you need to execute it in a new window, and why do you need to see the command in history? What is the bigger picture here?

PS: You forgot the output of 'echo $SHELL'. I'm going to assume it's /bin/bash.

Post Reply