linux

Convert .cshrc to .bashrc

I am new to Linux and I am trying to compile some code that needs environment variables set first. The script is in cshrc, but whenever I try to run that code I get "if: badly formed number" errors. I want to run it in bash instead. Is there an easy way to convert cshrc to bashrc? ...

Linux Shared Memory

The function which creates shared memory in *inux programming takes a key as one of its parameters.. What is the meaning of this key? And How can I use it? Edit: Not shared memory id ...

Determine the contents of Linux Cache

On a Linux device (using Android [Eclair] with a 2.6.29 kernel), I seem to have some contents in my cache that never go away. I would like to be able to examine the contents of my cache to find the culprit. I've looked at mount for any tmpfs that may be causing it, but they are taking up very little space. What other types of things co...

Linux rpm installs but cannot erase. Why?

My Perl code installed several (4) rpm files as root. the next install removes them (rpm -e) before installing a newer version. One does not remove, with rpm -e giving the error that it is not installed. However, later when the updated file is installed, the message is given that it is already installed. Manual attempts to remove give...

How to upgrade php on server running Plesk Virtuozzo!?

How on earth does plesk actually work? I have a VPS which is on centos 5.2 and has php 5.1.6. I have updated plesk to version 9.52 and it claimed to do some form of php update but it hasn't as far as i can see. How can i update to php 5.2 (centos 5.4) without breaking plesk Virtuozzo?! Plesk seems to be some kind of crazy black magic th...

What is linux equivalent of running a .bat file on windows from PHP using system()

I have a PHP script that runs a .bat file on my windows machine using $result = system("cmd /C nameOfBatchFile.bat"); This sets some environmental variables and is used to call Amazon EC2 API from the command line. How do I do the same from a Linux server? I have renamed my .bat file to a shell (.sh) and changed the script to use 'ex...

Error headers: ap_headers_output_filter() after putting cache header in htaccess file

Receiving error: [debug] mod_headers.c(663): headers: ap_headers_output_filter() after I included this within the htaccess file: # 6 DAYS <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$"> Header set Cache-Control "max-age=518400, public" </FilesMatch> # 2 DAYS <FilesMatch "\.(xml|txt)$"> Header set Cache-Control "max-age=172...

get the current date and use it in a filename

I'm trying to do something like this: mysqldump --user c1bt3 --password=blah c1bt3 > c1bt{date}.sql where date is replaced with the current date, i.e. c1bt5-11-10.sql, and I'm trying to do it from a linux shell script. Any ideas how I can do this? ...

How to take snapshot in linux - programmatically C++

I am currently involved in a project which requires me to repeatedly take snapshots of the screen. I am using qt's grabScreen function to do the same. The screen freezes for half a second every time the program takes a snapshot causing the computer to seem to be very slow :( Can anybody suggest me a better method of doing this ? ...

Newbie: Render RGB to GTK widget -- howto?

Hi All, Big picture: I want to render an RGB image via GTK on a linux box. I'm a frustrated GTK newbie, so please forgive me. I assume that I should create a Drawable_area in which to render the image -- correct? Do I then have to create a graphics context attached to that area? How? my simple app (which doesn't even address the r...

Unescpaing huge single-line string on Linux

I ended up with a huge, single line string literal (don't ask me how) where everything is escaped (mostly), including new lines and double quotes. Problem is, I want the original string. The string is huge so I'm not even sure how to begin. Here's what I have: "This\n is \"nice\",\nain\'t it?" This is what I want: This is "nice", ai...

How the kernel gives seg. fault for a scenario like this?

I have a doubt in accessing some invalid data. How can the OS cause a segmentation fault for a scenario like this: Suppose a chunk of data is 100 bytes long, aligned at the beginning of a 4K page. If we access the valid data within the first 100 bytes of the page, this will load the page into memory, and put the page table entry is in T...

Is there any way to get the combine two xml into one xml in Linux.

XML one is something like that: <dict> <key>2</key> <array> <string>A</string> <string>B</string> </array> <key>3</key> <array> <string>C</string> <string>D</string> <string>E</string> </array> </dict> XML Two is something like that: <dict> <key>A</key> <ar...

How does one find and copy files of the same extension, in different directories, to a single directory in linux?

So, How Do I find and copy all files, *.a that are in, ~/DIR{1,2,3,...} to ~/tmp/foo? ...

Rubygems on Debian: Gems won't load (LoadError)

I've installed the development version of Crunchbang, a linux distro based off Debian. I got Ruby and Rubygems installed, but I can't get the gems I've installed to load. Here is a command-line session: $ ruby -v ruby 1.9.1p378 (2010-01-10 revision 26273) [i486-linux] $ gem env RubyGems Environment: - RUBYGEMS VERSION: 1.3.6 ...

Linux: cat matching files in date order?

I have a few files in a directory with names similar to _system1.log _system2.log _system3.log other.log but they are not created in that order. Is there a simple, non-hardcoded, way to cat the files starting with the underscore in date order? ...

RSync copies only folder directory structure not files

I am using RSync to copy tar balls to an external hard drive on a Windows XP machine. My files are tar.gz files (perms 600) in a directory (perms 711). However, when I do a dry-run, only the folders are returned, the files are ignored. I use RSync a lot, so I presume there is no issue with my installation. I have tried changing permi...

Understanding how rpmbuild works

It seems that the RPM logic is quite different from what I know already and I am having some issues understanding the "RPM logic". For my work, I have to create a documentation on "How-to create a RPM package on Red Hat 5". I'm used to Debian and it's derivatives (Ubuntu, and so on) and thus to Debian packages (aka. .deb files). From ...

How do I know which illegal address the program access when a segmentation fault happens

Plus, The program runs on a arm device running Linux, I can print out stack info and register values in the sig-seg handler I assign. The problem is I can't add -g option to the source file, since the bug may won't reproduce due to performance downgrade. ...

Constructing a function call in C

Given that I have a pointer to a function (provided by dlsym() for example) and a linked list of typed arguments, how can I construct a C function call with those arguments? Example: struct param { enum type { INT32, INT64, STRING, BOOL } type; union { int i32; long long i64; char *str; bool b; } value; struct param *next; };...