General :: Bash Command History Update Before Execution Of Command
Jun 7, 2010
Bash's command history is great, especially it is useful when adding the history -a command to the COMMAND_PROMPT.However, I'm wondering if there is a way to log the commands to a file as soon as the Return key is pressed, e.g. before starting the command and not on completion of the command (using the COMMAND_PROMPT option would save the command once the prompt is there again).
I read about auditing programs like snoopy and session recorder like script but I thought they're already too complex for the simple question I have. I guess that deactivating that script logs all the output of the command would lead already in the right direction but isn't there a quicker way to solve that probelm?
I want to use ssh to execute a command and to wait endlessly to log everything (in file) that comes as a stream of the connected server. But unfortunately, in the manual its written "If command is specified, it is executed on the remote host instead of a login shell"
So what happens is that when I specify my command: ssh user@server "my_command"
It executed the command and the flow of execution returns to bash shell. So basically my session ends right after the command is executed. This happens only in case I specify command in the command line. If I login into ssh manually and then type "my_command", then the session doesn't end. I want the ssh not to exit, because after "my_command" executes, I want to capture everything in the session.
Up until now I've been using plink to remotely compile a project I'm working on. But recently the administrator from the remote server updated the distribution and messed up some configurations. My project has a lot of scripts written for tc shell (tcsh), and now the default shell is bash. There is no way to change this. Another problem is that now I need to run newgrp to change my default user group.
So... to work around this problem I've changed my .bashrc to run newgrp and then tcsh. If I do a normal connection using SSH, everything works as expected, but when using plink, or SSH to remotely execute commands, the shell gets stuck on the newgrp command. I think it's because both applications need a return value from newgrp to send the command I need to execute. Remotely running scripts that call a shell also get stuck like newgrp (newgrp also opens a new shell and that's why it gets stuck) my .bashrc is as follows:
Code:
user_grp=`id -g` if [ $user_grp != 4919 ]; then newgrp new_group_id else
I have a script which builds a project and then runs junit tests. However, if the build fails, the junit tests fail with the same error message.Therefore the command which runs the junit tests should only be executed if the build was successful.
I've been looking for how to set this up in bash with no luck so far. I can change what file the history log is written to, and how much history is saved. But it only writes the saved part when bash exits. Instead, I'd like to have bash write that file continuously as each command is entered (and maybe also do an fsync(2) to flush it to disk). That way I can see the command I crashed the box with Anyone know the magical incantation for that?
But there appears to be nothing that I can find there, in the man page, or other searches, that suggest it even can do continuous.
I have seen command like $rm aa dd cc bb ee then something like $ >> zz // it removes zz also Where aa dd cc bb ee zz are the files in my directory. Do not know exactly.
If someone has done something wrong on a shared linux machine. If i want to find out who is that person or ip from where it is been done what are all the possible ways. 1 possibility I thought was to get the PID of the command and get other details from that PID?
I was running scripts overnight from the command line (inside Screen on a Linux EC2 instance) and some errors that I was not tracking occurred. I want to "scroll up" or view more of the history in Screen, but I cannot seem to find any commands that will work. I need to see the onscreen output "further up" than I can on my current screen. CTRL + a is supposed to put me into scroll mode inside Screen, but it's not working.
Can anybody show me how to view command history of another user? I am an admin on my machine. I can see normal history by viewing /home/user_name/.bash_history but i can't see commands of that "user_name" when they were doing sudo. Is there a way to view all command executed by one user?
I just recently learned about the wonderful little lpr command- and using man -t (bash command) to beautifully print man pages for reference- but is there a way to print both sides of the paper using a printer so equipped?
I have a big bash script ,its goal is to download movie one by one . But I often get into a problem: if this script is executed in cron,it often does not completely download the movie.I often find the movies it downloaded are several KB while the movie is actually 20MB.So I think it is because it did not wait for finishing one task ,and jump to download another.So I want to know ,is there a way to force the bash script to wait until one movie downloaded completely and then start to download another movie ?
I create a bash script that writes another bash file. But in the generated bash file I want to write a bash command in the file and not executing it.Here's my bash file:
Code: #!/bin/bash cat > ~/generateGridmix2data.sh << END
I've just installed java (jre-6u21-linux-i586.bin) on Red Hat 4.4 AS and issued this command to check the java version: java -versionand got :bash :java: command not found
Problem started after installing a new firewall in my network. originally after installing the firewall there would be a 10 second delay after entering a command before it was processed, the command would be executed however there would be an error, i forget what it said, something about not being able to resolve my domain name (and it would give my domain name). i realized this was a problem with my NAT, so i configured DNS forwarding on my firewall so that any attempt to access my server using my domain name from inside the network would point back at my server. after setting up the DNS forwarding i no longer receive the error about my domain name being unreachable, however there is approximately a 30s delay between entering a command and its execution.
the problem is hardly critical i do not see any more serious problems, it is just a pain to do any work when every time i try to do something i have to wait for it to execute.
How do I create a command to launch a program and then have the terminal wait for a specified time and then move on to the next command?I'm wanting to create a startup script, and I need program B to wait until program A has finished loading up.
and I want it to execute via ssh on a remote machine through a script. Therefor I need to escape it properly. Because of the massive use of regular expressions and commandline options, this is not an easy task. Is there any (online) utility that will escape that for bash use? I suppose pasting the code in vi and doing some search and replaces should do the trick. But for that I would need a list of characters to escape...
I'm not quite sure what's up with this, but when I change the title of a terminal away from the default (e.g. to represent which project that terminal is to be used for), it changes back to the default (user@host:path), but only on the task bar at the bottom of the screen, listing the open windows.
If I change tabs in the terminal and then change back, it displays again at the bottom of the screen, but as soon as I execute another command (e.g. ls), then it resets again. That's quite annoying, as I like to have a few terminals open, each with a set of tabs pertaining to a particular project. The fact that I can't see from the title on the taskbar which is which means I have to guess/remember/check them all...