bash

Make "make" default to "make -j 8"

Is there a way that I can make $ make default to: $ make -j 8 ? Thanks! ...

Bash open Firefox Window, then each subsequent window in tabs

Hi Folks, I know as long as Firefox has the "New pages should be opened in - a new tab" selected, the following code will open specified urls in new tabs to the firefox window last selected. firefox '<url here>' Works great. However with many tabs to open the user needs to leave computer as until all open as desired. Is it possible...

How to recursively list subdirectories in bash without using find or ls commands?

I know you can use find command for this simple job. But I got an assignment not to use find or ls and do the job. Please help.... ...

Running Different Bash Commands Based on Java Version

I'm trying to develop a bash build script for a Java project that will be run on Ubuntu and Fedora. Ubuntu uses the gcj compiler while Fedora uses IcedTea. Both report their errors and warning in slightly different ways, and I want to ignore the warnings (I know, not generally a good idea, but some of the warnings are simply idiotic). ...

Way to automatically detect wrong log4j static initialization

(Note that it's more of a Bash question than a Java question, see note below) When configuring log4j in each class, we do the following: public class Example { private static final Logger log = Logger.getLogger( Example.class ); The problem is that we now have a medium-sized codebase (200K LOC) containing a lot of Java classes and...

Script: SSH command execute and leave shell open, pipe output to file

I would like to execute a ssh command and pipe the output to a file. In general I would do: ssh user@ip "command" >> /myfile the problem is that ssh close the connection once the command is executed, however - my command sends the output to the ssh channel via another programm in the background, therefore I am not receiving the output...

Simplest way to get a PTY in Linux C++

Hello, all. I am programming something that needs an interface to Bash. At first I thought I could just use popen or QProcess. ( I'm using QT C++ ) They work fine but I can't get them to run Bash in a tty, which you need if you are going to use anything like sudo, which requires a tty/pty to accept a password. I found some things like ...

bash, find files which contain numbers on filename

Hi, in bash, I would like to use the command "find" to find files which contain the numbers from 40 to 70 in a certain position like c43_data.txt. How is it possible to implement this filter in find ? I tried file . -name "c**_data.txt" | grep 4, but this is not very nice Thanks ...

powershell bash loops are randomly stuck waiting for keyboard input

Hi all, I am facing a curious issue. I have bash script I am running from powershell in windows that does a for loop. Every once in a while, one of the loop iteration hangs until I hit enter on the keyboard. This doesn't happen all the time, in fact, it happens pretty rarely. But it still does. The interesting thing is that my loop...

Viewing full output of PS command

Hi, when I run ps -aux command on my linux server, to which I connected using putty, few processes are too long to fit in my current window width. Is there an alternative? Thank you -- Update -- I am sorry for downgrading,I thought others won't find the answer useful too, so I downgraded. Here is the info you asked for. hadoop-use...

How do I check in bash if a process (or one of its children) is actually doing something (CPU/IO)?

Actually, I would like to have some kind of progress bar. I would like for the user to be able to recognize when the process "hangs". Usually I will use it to show the progress of ./configure and make calls. ADDENDUM: I need progress that makes no use of external tools. (no bar) /proc/pid/stat is ok, but doesn't solve the problem abou...

Is there a way to make a shell become interactive in the middle of a script?

I'd like to do something like: do lots of stuff to prepare a good environement become_interactive #wait for Ctrl-D automatically clean up Is it possible with bash? If not, do you see another way of doing the same thing? ...

MongoDB external script file

Hey, I am using mongoDB and am curious to whether you can import scripts like you can in MySQL: mysql -uuser -ppassword database < script.sql Can you do this with mongoDB? Cheers Eef ...

Why do I have to press Ctrl+D twice to close stdin?

I have the following python script that reads numbers and outputs an error if the input is not a number. import fileinput import sys for line in (txt.strip() for txt in fileinput.input()): if not line.isdigit(): sys.stderr.write("ERROR: not a number: %s\n" % line) If I get the input from stdin, I have to press Ctrl+D twice...

Horizontal scroll in a bash window

I used printf to output a columnar display of a text file. However the length I wanted will cause the columns to flow into the next line. I've been searching for a flag or workaround that will make the console window scroll and could only come across the following: set horizontal-scroll-mode On It's right under the #! /bin/bash line,...

Writing bash script to read, compare, and verify external IP address. Need help.

I'm a bash newbie and am having trouble writing a simple script to see whether the server that is calling the script is the one I want to execute the script. Getting the external IP is easy and there are plenty of other posts about it. I'm having trouble with the IF statement, though. #!/bin/bash if [ wget -q -O - checkip.dyndns.org...

Program Interaction and testing via bash script

I've just completed the coding section of simple homework assignment for my C++ class. The second part of the assignment requires us to verify our code's input validation. (The program takes several different values as inputs from a user and prints those values to a file) I was hoping that I could use bash script for this. Is there a...

G++ and sed pipeline

Hello, I would like to replace all "no" by "on" in the console output of g++. I tried $ g++ | sed -e 's/no/on/g' But it shows i686-apple-darwin9-g++-4.0.1: no input files instead of i686-apple-darwin9-g++-4.0.1: on input files ...

Give the mount point of a path

The following, very non-robust shell code will give the mount point of $path: (for i in $(df|cut -c 63-99); do case $path in $i*) echo $i;; esac; done) | tail -n 1 Is there a better way to do this? Postscript This script is really awful, but has the redeeming quality that it Works On My Systems. Note that several mount points may...

bash script to restart Apache automatically

I wrote a bash script to restart Apache when it hanged and send email to the admin. The code is shown below. the code will restart Apache if the number of Apache process is zero. The problem is: Apache some time hangs and processes is still not zero,so in this case the script will not restart Apache. The needed is: how do I modify the co...