linux

SSH listen for incoming connections and make an outgoing connection

How to configure openSSH on ubuntu to listen on a local port, and forward the ssh connection to a remote server, only after the connection has been received. If I use ssh -D or ssh -L, they make the connection immediately to the remote server. A proper configuration using nc will also be ok. ...

Hudson jobs and slave node are missing after an upgrade

Where and how are Hudson jobs and slave information stored? I accidentally canceled a Hudson upgrade today. It wouldn't permit me to continue the upgrade; only to downgrade to the previous version and then upgrade again. After I downgraded, the two jobs I had created in the recent past were gone from the dashboard along with the slave n...

ifstream fails to open in recursive calls

hello. we are running into an odd issue when trying to parse an input file. the idea is that this file can include other files, which must be parsed as well. We are doing this recursively in a function defined as int parse_inp(const char* filename) The main file parses no problem, but recursive calls cannot open their file streams. ...

linux, write() system call returns -1 while attempting to write to file.

In the below program write() returns -1 while writing to a file. #include<sys/types.h> #include<sys/stat.h> #include<fcntl.h> #include<stdio.h> #include<unistd.h> #include<stdlib.h> int main() { int fd_r=0,fd_w=0; int w_ret=100; fd_r = open("reader.txt", O_RDONLY); fd_w = open("writer.txt",O_C...

Debugging slow functions in C programs (built by gcc)

Having source like this: void foo() { func1(); if(qqq) { func2(); }; func3(); func4(); for(...) { func5(); } } I want to obtain info like this: void foo() { 5 ms; 2 times; func1(); 0 ms; 2 times; if(qqq) { 0 ms; 0 times; func2(); 0 ms; 2 times; }; 20 ms; 2...

Eclipse: editing and running code live

When editing Java code in Eclipse I can modify the code while it's running in various ways and have those changes take effect without restarting my program. What is the technology underlying this feature? Is it part of Eclipse, or is it something I can do with the command line tools and the tools that come with the JDK? ...

WebDriver Selenium API: FirefoxDriver on linux ??

has anyone been successful in running tests using FirefoxDriver on a linux distro ? If so, which distro are you using ? Are you using xvfb ? right now, I am thinking of simply using windows 2003 server, but it's a bit more expensive and I am more familiar with linux environment. ...

How to run exe before or after "RunProgram" from 7zip sfx files setting on config.txt?

I am using 7zip to pack an installation (im using 7z because i need it to work in linux and windows). From what i've been reading the config.txt file can contains this: ;!@Install@!UTF-8! RunProgram="Installer.exe" ;!@InstallEnd@! But what if i need to run another exe before or after running installer.exe? Is it possible like it is i...

How does cron internally schedule jobs?

How do "modern" cron daemons internally schedule their jobs? Some cronds used to schedule a run every so often via at. So after a crontab is written out, does crond: Parse the crontab for all future events and the sleep for the intervals? Poll an aggregated crontab database every minute to determine if the current time matches the sc...

getting selected text in current window

I'm trying to build a script that will add the currently selected text to the end of a file. So far it looks like cat selected_text >> quotes.txt. Is there any way, either in command line or in C/C++ to get the currently selected text from the currently active window? ...

How to ensure a rake task only running a process at a time

I use crontab to invoke rake task at some time for example: every 3 hour I want to ensure that when crontab ready to execute the rake task it can check the rake task is running. if it is so don't execute. how to do this. thanks. ...

Get active window title in X

I'm trying to get the title of the active window. The application is a background task so if the user has Eclipse open the function returns "Eclipse - blabla", so it's not getting the window title of my own window. I'm developing this in Python 2.6 using PyQt4. My current solution, borrowed and slightly modified from an old answer here ...

Keyboard/Mouse hooks in python in X

What's a good way of getting keyboard/mouse events in Python in X? I don't the actual character, just the event that any key or mouse button has been pressed. I'm developing this using Python 2.6 and PyQt4. On windows pyHook was dead easy to get going, seems harder to get something working on Linux. I read an old answer about XGrabKeyb...

tilde expansion in environment variable

In my .sh file, I have this, cp $file $SOME_PATH, while $SOME_PATH is exported as export SOME_PATH="~/path/to/path/". But when I ran this .sh file, I got error message saying like * no such "~/path/to/path/" exists.* I replaced ~ as $HOME, then the error was gone. So what's up here with the tilde? Thanks in advance. ...

daemon process killed automatically

Recently I run a below command to start daemon process which runs once in a three days. RAILS_ENV=production lib/daemons/mailer_ctl start, which was working but when I came back after a week and found that process was killed. Is this normal or not? Thanks in advance. ...

sudo permission denied

I ran this code: sudo cat <<EOF | sudo sed -e "s,%,$,g" >/etc/init.d/dropbox echo "Hello World" EOF But even though, I get "permission denied", cause you have to be root to make changes in the /etc/init.d directory. And somehow, my command above doesn't work. Is there a way to solve this? ...

"sed" command in bash

Could someone explain this command for me: cat | sed -e 's,%,$,g' | sudo tee /etc/init.d/dropbox << EOF echo "Hello World" EOF What does the "sed" command do? ...

man 2 stat - how to figure out if a file is a link

I have the below code only a part of it is shown here and I am checking if a the type of file. struct stat *buf /* just to show the type buf is*/ switch (buf.st_mode & S_IFMT) { case S_IFBLK: printf(" block device\n"); break; case S_IFCHR: printf(" character device\n"); break; case S_IFDIR:...

i got to clarify what is /bin/sh/ -c !

correct me if i'm wrong its the path location where the shell cmds resist and interpreted as C prog. so that if a cmd is passed it will call that function lokking in /bin/sh plz kindly guide me if im wrong ...

newbie in bash scripting assistance please

Hi all I run bash scripts from time to time on my servers, I am trying to write a script that monitors log folders and compress log files if folder exceeds defined capacity. I know there are better ways of doing what I am currently trying to do, your suggestions are more than welcome. The script below is throwing an error "unexpected en...