save shell history

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
mvrk
DD-WRT Novice


Joined: 20 Oct 2009
Posts: 44
Location: Czech Republic

PostPosted: Tue Sep 19, 2017 11:36    Post subject: save shell history Reply with quote
Hi,

I'm trying to save shell history to my /jffs partition but isn't working.

I have this in .profile:

export HISTFILE=/jffs/.ash_history

But it doesn't save anything, anyone has any idea?
Sponsor
home@karlperkins.com
DD-WRT Novice


Joined: 15 Aug 2018
Posts: 3

PostPosted: Wed Aug 15, 2018 13:12    Post subject: Re: save shell history Reply with quote
I'm struggling with the same thing, and can't get command history to save either. It does save on another router that I have, which is running a completely different distro (not DD-WRT), but it has the same version of busybox (installed via opkg). Did anyone ever figure this one out?

mvrk wrote:
Hi,

I'm trying to save shell history to my /jffs partition but isn't working.

I have this in .profile:

export HISTFILE=/jffs/.ash_history

But it doesn't save anything, anyone has any idea?
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12887
Location: Netherlands

PostPosted: Wed Aug 15, 2018 17:24    Post subject: Reply with quote
Is there a /jffs partition and is it writable?
you can check with WinSCP

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
home@karlperkins.com
DD-WRT Novice


Joined: 15 Aug 2018
Posts: 3

PostPosted: Fri Aug 17, 2018 10:42    Post subject: Reply with quote
Not using jffs, I'm using a real HD plugged in via USB. Mounted as /opt (so using entware packages too). I have mapped a new profile over /etc/profile (too override the default /etc/profile). This is done in a startup script, and is documented in the DD-WRT documentation: -

Code:
sleep 40
logger "*** Attempting /opt STARTUP ***"
/opt/etc/init.d/rc.unslung start
mount --bind /opt/etc/profile.new /etc/profile

/tmp/root is replaced on bootup with a symlink to /opt/home/root (so it's on the HD, and not in RAM).

The obvious thing here is that this in the /etc/profile: -

Code:
export HISTCONTROL='ignoredups'
export HISTFILE='/opt/home/root/.ash_history'
export HISTSIZE='50'
export PS1='\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '

...and it has absolutely no effect on ash writing history (.ash_history never has any history written to it). The .ssh/ directory is working as expected, and knows about all the hosts I've ever SSH'ed to, for example, so there's nothing wrong with /opt/home/root being the home directory. It's almost as if ash has been disabled somehow from writing the .ash_history file. In the same /etc/profile, I also change a bunch of other variables (like the command prompt), so I 100% know it's running and ash is reading it. It just seems to be ignoring the $HISTFILE setting, for no good reason I can see.


egc wrote:
Is there a /jffs partition and is it writable?
you can check with WinSCP


Last edited by home@karlperkins.com on Fri Aug 17, 2018 10:57; edited 2 times in total
home@karlperkins.com
DD-WRT Novice


Joined: 15 Aug 2018
Posts: 3

PostPosted: Fri Aug 17, 2018 10:45    Post subject: Reply with quote
There's nothing in my .ash_history. I touched it, to create an empty file, and there's still nothing that ever gets written into it. It's a good suggestion, but there's nothing to copy. It is like ash has somehow been disabled from writing to .ash_history, even though all the right environment variables have been set. See my posting above for more details of how everything is set up.

I've also done some further testing, and copied over an .ash_history from a router running a different distro. From this, I can tell that ash isn't even reading .ash_history, which is quite unexpected. I then installed bash, and it is able to read/write a history file, as you would normally expect.

eibgrad wrote:
Using tomato, I use the shutdown event to copy the contents of .ash_history in the home directory to /jffs, then copy that file back to the home directory in the init event. I imagine you could something similar w/ dd-wrt, although afaik, dd-wrt doesn't have a shutdown event, only the startup event. So perhaps you'd need to periodically copy .ash_history to /jffs using the scheduler.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
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 can attach files in this forum
You can download files in this forum