linux

Executing shell script with system() returns 256. What does that mean?

I've written a shell script to soft-restart HAProxy (reverse proxy). Executing the script from the shell works. But I want a daemon to execute the script. That doens't work. system() returns 256. I have no clue what that might mean. #!/bin/sh # save previous state mv /home/haproxy/haproxy.cfg /home/haproxy/haproxy.cfg.old mv /var/run/ha...

How run in a chroot jail not as root and without sudo?

I'm setting up a minimal chroot and want to avoid having sudo or su in it but still run the my processes as non-root. This is a bit of a trick as chroot requiers root. I could write a program that does this that would look something like: uid = LookupUser(args[username]) // no /etc/passwd in jail chroot(args[newroot]) cd("/") setuids(u...

How to open and write/read to a USB CDC "serial" device on Windows, Linux, OS X?

I've got an Atmel AVR A90USBxxxx device that I have configured to "talk USB" via CDC. It's designed to take input from a Host computer, running Windows, Linux, or OS X. I'm under the impression that Linux and OS X will immediately recognize this CDC device, and with a simple .inf a Windows machine can be told my VID/PID should be opene...

Reading USB input stream on linux

Hello, I'm currently working on an embedded linux machine. Im trying to read a USB devices input stream but for some reason I dont have any such thing in my /dev directory. I would assume it would be something like /dev/ttyUSB01 or /dev/input/usb or something similar but it's not there. dmesg returns the following [ 195.863911] input: G...

what api can be used to create a hard link to an existing inode on ext2/3

I did a big oops, but the file is still open and in use. Following (http://stackoverflow.com/questions/1178593/link-to-a-specific-inode), copying from the /proc/###/fd/### to a new file is not useful because: the file is changing The filesize is 40G and the disk is full (150MB free) I am attempting to relink it to the filesystem (u...

Remove a file's "read only" attribute in vim after editing it and saving with :w!

I want to change the read only attribute from a file when I save it with :w! in vim. How do I do it? (I don't mind if I have to call an external script). I'm using Linux. I know I can use an external script using this command: autocmd BufWrite /tmp/* !sh /tmp/script.sh. So, I would like to call a chmod command when :w! is invoked: the ...

Opening a terminal from Linux Makefile

Hi, Can we open a new terminal tab or window from the existing terminal using a makefile or some c file. If yes how? Thanks in advance for replying. P.S. I want to do this because first in the terminal I want to run the server file then I want to open the new terminal and there run the file for the client. From the second terminal I ...

Alternative to Up Arrow + Enter to run previous command?

Sometimes I have to run a command many times in succession, for example to see if a service has started, and it becomes tedious to move my hands away from my normal typing position to press the Up Arrow and Enter keys repeatedly. Is there a way to run the previous command without the Up Arrow and Enter keys, perhaps with an elaborate she...

Linux bash read output explanation

Hi, I would like to understand the values I get from read command in console. Are these outputs combinations of some keys? F2 ^[OQ F3 ^[OR F4 ^[OS ESC ^[ My problem is that I use special 128 keys keyboard that is programmed for specific software. I need to send these "keys" into this software using code below. Don't be confuse...

How to set chmod for a folder and all of its subfolders and files in Linux Ubuntu Terminal?

So I want a way to set chmod 755 to /opt/lampp/htdocs and all of its content including subfolders and files, and If I create a new folder or file the chmod of that should be also 755. chmod 75 /opt/lampp/htdocs works but only for this folder :| ...

How to set default CHMOD in LINUX terminal?

Previous Question just to understand what I'm doing: How to set chmod for a folder and all of its subfolders and files in Linux Ubuntu Terminal? So if I change the chmod to 755 for chmod 75 /opt/lampp/htdocs and I restart the system I want the files to be in chmod 755. ...

gcc compiled binaries give "cannot execute binary file"

Hi- I compile this program: #include <stdio.h> int main() { printf("Hello World!"); return 0; } With this command: gcc -c "hello.c" -o hello And when I try to execute hello, I get bash: ./hello: Permission denied Because the permissions are -rw-r--r-- 1 nathan nathan 856 2010-09-17 23:49 hello For some reaso...

How can I get the architecture of a '.a' file?

I have a .a file from which I want to get architecture information. Running file myFile.a results in file.a: current ar archive. How can I get more information on what architecture the file contains? ...

Why doesn't the cd command work in my shell program?

When I created my own shell, I am not able to execute cd command which I am able to do in the Linux shell. Why is that? ...

Threads vs Processes

Possible Duplicate: What are the thread limitations when working on Linux compared to processes for network/IO-bound apps? What is meant by context switches in threads or processes ? Also which is better : Threads or Processes ? I mean which is more space efficient and which is more time efficient ? ...

Make gdb quit automatically on successful termination?

I use a debugging script that runs several related processes in succession with the debugger. I'm currently using -x to execute several commands automatically (such as run). How can I make gdb quit automatically when the debugged process successfully terminates? Adding a quit command to the command file will cause that command to be hand...

Creating new tmp folder for PHP to use?

Hi, I think I'm having problems using PHP sessions because I've got cPanel installed on the same server and I believe it has additional security in place that prevents write access to /tmp I can set a new folder, but am unsure what permissions / owners should this folder have. Also where should it ideally be located? ...

Compiling a fat executable with gcc

This is not essential for my programs, but merely out of curiosity. Is it possible to, preferably using gcc, compile a 'fat' binary for Linux including multiple architectures such as combinations of amd64, i386, lpia and powerpc? ...

Mysterious output for <cmd> followed by \ or `

Sometimes when I type a command in bash, I mistakenly type in the \ character at the end, as it is close to the Enter key. Whenever I do this, I get a prompt on the next line, like this: >_ The same output is produced when the ` character is used. What exactly does this \ do to the command? Are there other characters (besides \ an...

Location of cd executable

I read that the executables for the commands issued using exec() calls are supposed to be stored in directories that are part of the PATH variable. Accordingly, I found the executables for ls, chmod, grep, cat in /bin. However, I could not find the executable for cd. Where is it located? ...