linux

How do you run ShellScript on Windows?

I'm just a student and I'm learning ShellScript in my college. In college lab, our ma'am just asked to enter and IP in PUTTY and launch it, open vi editor and do programming. How do I do it at home? I run XP on my computer. I tried asking her, but God bless her, she doesn't even know the syntax of if ... else and she came to teach us. ...

C++, windows->linux porting, mapfile problem

Hello. I'm porting a small C++ console application from windows to linux, GCC 4.3.2. When compiling I get strange error that I'm unable to solve. Labels.cpp: In function ‘void DumpSymbols()’: Labels.cpp:68: error: invalid conversion from ‘int’ to ‘std::_Ios_Openmode’ Labels.cpp:68: error: initializing argument 2 of ‘std::basic_ofstrea...

How do I write a C++ program that will easily compile in Linux and Windows?

I am making a C++ program. One of my biggest annoyances with C++ is its supposed platform independence. You all probably know that it is pretty much impossible to compile a Linux C++ program in Windows and a Windows one to Linux without a deluge of cryptic errors and platform specific include files. Of course you can always switch to ...

Python and os.chroot

I'm writing a web-server in Python as a hobby project. The code is targeted at *NIX machines. I'm new to developing on Linux and even newer to Python itself. I am worried about people breaking out of the folder that I'm using to serve up the web-site. The most obvious way to do this is to filter requests for documents like /../../etc/pa...

Broken pipes in C -- pipe(), fork(), exec() program

Hello, I need to write a simple program: There will be a Parent and a few programs [children] (started via execl in Parent). Children communicate to one another in this way: Child I sens to Parent number J, Parent sends a message (something like -- "there is a message to you") to J, J send to Parent number K etc. etc. And there is a pr...

mdfind equivalent on linux?

ok, so I finally got a Macbook pro and to tell the truth I am astonished by both the architecture, speed, and os on this laptop. Mac OS X is a beautiful system, from the mach kernel up to finder and spotlight and speaking of spotlight, it truly blew me away when I just needed to execute this command to get all unix executables and ONLY ...

Linux newbie: Linux vs POSIX manual

$ apropos mkfifo mkfifo (1) - make FIFOs (named pipes) mkfifo (1posix) - make FIFO special files mkfifo (3) - make a FIFO special file (a named pipe) mkfifo (3posix) - make a FIFO special file mkfifoat (3) - make a FIFO (named pipe) relative to a directory file ... So I have man pages for Linux Pro...

How to find out the free disk space for a given path on a linux shell?

1) I am in some directory 2) I want to find out how much free space is left there Is there a simple command that does this? I don't want to look in fstab or whatever, having to map the devices & mount points in my mind in order to determine how much free space I have left. ...

Should I fsck ext3 on embedded system?

We have a number of embedded systems requiring r/w access to the filesystem which resides on flash storage with block device emulation. Our oldest platform runs on compact flash and these systems have been in use for over 3 years without a single fsck being run during bootup and so far we have no failures attributed to the filesystem or ...

how to find out which processes are swapping in linux?

Under Linux, how do I find out which process is using the swap space more? Any scripts/links appreciated.. ...

Linux/c++ log rotation scheme

I have a logger system which basically is a fancy way of writing my data to std::clog in a thread safe way. I also, redirect std::clog to a file like this: int main() { std::ofstream logfile(config::logname, std::ios::app); std::streambuf *const old_buffer = std::clog.rdbuf(logfile.rdbuf()); // .. the guts of the applicat...

Linux error while loading shared libraries: cannot open shared object file: No such file or directory

Program is part of the Xenomai test suite, cross-compiled from Linux PC into Linux+Xenomai ARM toolchain. # echo $LD_LIBRARY_PATH /lib ...

How to discover the machine type?

Hi, I would like to discover the machine architecture type of a big number of machines. I have the hostname of each machine. The machines have Debian 4 linux, SunOS 9, SunOS 10 or Apple Darwin. All are unix-like, but with minor differences. I would like to know: - architecture (x86, x86_64, ia64, sparc, powerpc...) - processor type (in...

Java: Handle logoff or shutdown on Windows and Linux

Is there a way for a Java GUI application to respond to system shutdown or logoff events, other than to use JNI? (On Windows, the JNI would use WM_QUERYENDSESSION, on Linux?) The method should allow the program to prompt users to save, etc., and then continue the logoff process. ...

changing pseudo tty echo mode from the master side

On linux, I am opening a pseudo tty on the master side. While there is no client on the slave side, the pseudo tty seems to be echoing everything I am writing to him, which is not what I am expecting. Consider the folowing code : int main(int argc, char * argv[]) { int ptyfd; int rc; /* return code */ char readbuf[3]; ...

How to mount from command line like the Nautilus does?

On my Ubuntu linux box I can easily mount USB connected drives or CDROM clicking on devices icons that I can found on the Desktop. For example if I click on a USB connected drive icon the following things happen: a /media/LABEL directory is automatically created (where LABEL is the label of the disk and may vary from disk to disk) the...

How should I log from a non-root Debian Linux daemon?

I'm writing a new daemon, which will be hosted on Debian Linux. I've found that /var/log has root only write permissions, so my daemon cannot write log files there. However, if it writes there, it appears it will gain automatic log rotation, and also work as a user might expect. What is the recommended way for a daemon to write log en...

Dynamic Shared Library compilation with g++

I'm trying to compile the following simple DL library example code from Program-Library-HOWTO with g++. This is just an example so I can learn how to use and write shared libraries. The real code for the library I'm developing will be written in C++. #include <stdlib.h> #include <stdio.h> #include <dlfcn.h> int main(int argc, char **...

Linux Socket Buffer Imbalance

I have a simple scenario, where two servers are connected through a gigabit link. I run iperf on both sides to measure the throughput. What surprises me, whenever I run the traffic bidirectionally, it always favor one side only (eg. ~900Mbps vs. ~100Mbps). If I run the traffic unidirectional, each side got ~900Mbps. If I connect one of...

OpenGL performance difference on Linux and WindowsXP

I've noticed that a OpenGL app I've been working on has significant performance difference when run on Linux vs WindowsXP. Granted, there are a lot of textures and shadow buffers but I would estimate that the app runs about 10x slower on Windows XP. Any ideas? Any suggestions for porting the code to DirectX? Can that be done easily...