unix

Does the Unix kill command insure that dynamically allocated memory will return properly?

So, I found a bunch of scripts in the project I have been newly assigned to that are the "shutdown" scripts. They just do some basic searches and run the unix "kill" command. Is there any reason they shouldn't shut down the process this way? Does this insure that dynamically allocated memory will return properly? Are there any other ...

What is a good Linux exit error code strategy?

I have several independent executable Perl, PHP CLI scripts and C++ programs for which I need to develop an exit error code strategy. These programs are called by other programs using a wrapper class I created to use exec() in PHP. So, I will be able to get an error code back. Based on that error code, the calling script will need to ...

Best Books for getting up to speed in all things UNIX

I have been hacking around on UNIX servers for a while now, I love Debian, its a great server OS. But I feel like I don't really grasp the entire system and overall environment of UNIX. More and more, server maintenance and configuration is becoming a bigger part of my life and I am looking for some great book recommendations. Keep in ...

Using knockd to do stuff | Sending TCP/UPD Requests via PHP

I was wondering, whether knockd http://www.zeroflux.org/cgi-bin/cvstrac.cgi/knock/wiki would be a good was to be able to restart apache without logging into ssh. But my programming question was whether there is a way to send tcp/udp packages via PHP so I can knock via a webclient. I am aware that this is not the safest way of doing it, ...

How to create ClearCase views automatically?

I'm a configuration manager and I'm working on Windows and UNIX environments. Currently, I have to create the views by myself for the developers and QA engineers. Is there any better approach? Thanks. ...

Blocks to KB/MB/GB from statfs on iPhone

I am using statfs() which gives me the free blocks available to a non-superuser. I am unsure how to convert this into KB/MB/GB. The values that are returned are: fundamental file system block size: 4096 total data blocks in file system: 3805452 free blocks in fs: 63425 free blocks avail to non-superuser: 63425 total file nodes in file...

How can I process a list of files that includes spaces in its names in Unix?

I'm trying to list the files in a directory and do something to them in the Mac OS X prompt. It should go like this: for f in $(ls -1); do echo $f; done If I have files without spaces in their names (fileA.txt, fileB.txt), the echo works fine. If the files include spaces in their names ("file A.txt", "file B.txt"), I get 4 strings (fil...

Using getopts in bash shell script to get long and short command line options

I wish to have long and short forms of command line options invoked using my shell script. I know that getopts can be used, but like in Perl, I have not been able to do the same with shell. Any ideas on how this can be done, so that i can use options like: ./shell.sh --copyfile abc.pl /tmp/ ./shell.sh -c abc.pl /tmp/ In the above, bo...

Comparing Unix/Linux IPC

Lots of IPCs are offered by unix/linux : Pipes/sockets/shared memory/dbus/message-queues. I would like to know what are the respective most suitable applications , e.g. what are the places where shared memory are preferred over message queue and vice versa. Also looking for data comparing their performances. Tried googling and st_over...

What are the most often linux (power) commands that you use?

To find files containing a particular string, I use this often find . -name * | xargs grep -iH "string" ...

dlopen on library with static member that throws exception in constructor - results in Abort

I am trying to load a dynamic library using dlopen function. This library contains a static object, which throws an exception in its constructor. I have a "try-catch(...)" block around the dlopen call, but it doesn't catch the exception, and I just see "Abort" printed. How am I able to catch this exception? ...

How do I get a Remote Desktop for Linux (XDMCP, VNC)

I do this all the time using VNC and it is very easy, but I am curious about a few things like XDMCP. As I understand it, this is a way of creating the entire desktop on a remote X-Server which seems fairly elegant. Several years ago, I worked on a Solaris server and multiple developers had X-Servers running in Windows and we were able ...

How to do a mass rename?

I need to rename files names like this "transform.php?dappName=Test&transformer=YAML&v_id=XXXXX" to just this "XXXXX.txt" How can I do it? I understand that i need more than one "mv" command because they are at least 25000 files. Thanks! ...

What's an easy way to trim N lines from the tail of a file (without the use of 'head')?

Say I've got a bunch of files that are all >100 lines long. I'd like to trim off the top 14 lines and the bottom 9 lines, leaving only the lines in the middle. This command will trim off the top fourteen: cat myfile.txt | tail -n +15 Is there another command I can pipe through to trim off the bottom 9 without explicitly passing the ...

How a Windows Developer can most easily get his software to work well under Wine

Many of my users have been telling me that they'd like to run my software on their Linux machines under Wine. But I'm a Windows Developer who has practically no experience with Linux. Now I could spend a month or two installing Linux, learning Linux, installing Wine, learning Wine, and thoroughly ensure my application runs well under W...

How can a bash script know the directory it is installed in when it is sourced with . operator?

What I'd like to do is to include settings from a file into my current interactive bash shell like this: $ . /path/to/some/dir/.settings The problem is that the .settings script also needs to use the "." operator to include other files like this: . .extra_settings How do I reference the relative path for .extra_settings in the .setti...

Can I symlink multiple directories into one?

I have a feeling that I already know the answer to this one, but I thought I'd check. I have a number of different folders: images_a/ images_b/ images_c/ Can I create some sort of symlink such that this new directory has the contents of all those directories? That is this new "images_all" would contain all the files in images_a, imag...

When learning Java, how important is it to know Unix well?

Hi, Other than the Java language itself, you have to learn the java framework. Similiar to how you have to learn the .net framework in addition to the language (C#/VB). How important is it to know unix? Or rather, what unix areas should one focus on? Seeing as many people run java based applications (desktop/web) on unix boxes, what...

Line completion with custom commands

Hi, my Python program can be launched with a range of different options (or subcommands) like: $ myProgram doSomething $ myProgram doSomethingElse $ myProgram nowDoSomethingDifferent I want it to use auto-completion with so that if i type "myProgram d" it returns "myProgram doSomething" and if i type "myProgram n" it renders "myProgr...

How to extract a text part by regexp in linux shell?

How to extract a text part by regexp in linux shell? Lets say, I have file where in every line is an IP address, but in different position. What is the most simple way to extract those IP addresses using common unix command-line tools? ...