unix

Reading into directory, unix shell script

I am trying to analyze the files/directories inside of a directory using a shell script, for example if the file is readable, if it is a file, if it is a directory, etc. My script is set up to take a directory as input. so I would type 'file.sh directoryname'. However, when I create a for loop to analyze the files, it analyzes the files ...

Is there a way to find the running time of the last executed command in the shell?

Is there a command like time that can display the running time details of the last or past executed commands on the shell? ...

How do you expand variables in UNIX/BASH?

Nested variables have prevented me from trying to use BASH more extensively... consider the following: export SYS_DIR='/home/${LOGNAME}/sys' export APP_DIR='${SYS_DIR}/app' I always end up with > set APP_DIR=/home/${LOGNAME}/sys/app why? lol and how do I get what I want =/ I'm not trying to resolve ${${var}}, but rather actual st...

How do you assign the value of a parameter to a variable in UNIX?

#!/bin/bash if [ ! $1 ] then echo "no param" else set FAV_COLOR=$1 echo "My fav color is ${FAV_COLOR}" fi This is not working how i expected: >favcol.sh blue My fav color is FAV_COLOR=blue any thoughts? ...

The conventional location for storing my Java libraries and applications in UNIX based systems

I usually store the Java applications and JAR files that I download from the Web in the ~/Java folder on my computer (an OS X machine). I have been doing this since the days when I was a Windows user. However I think in UNIX based systems user local apps are conventionally stored in another directory. I have a feeling that this directory...

write error: Broken pipe

Hi, I have to run a tool on around 300 directories. Each run take around 1 minute to 30 minute or even more than that. So, I wrote a python script having a loop to run the tool on all directories one after another. my python script has code something like: for directory in directories: os.popen('runtool_exec ' + directory) But whe...

Multi Forks controlled by main parent pipe

I have this code, it work fin but if i change NUM_CHILDREN = 2 or any other number "not equal 1" it bad file descriptor. why is that? #include <stdio.h> #include <unistd.h> enum { NUM_CHILDREN = 1 }; static int pipes[NUM_CHILDREN][2]; void start_encoding(void) { pid_t d, h; int pipe_master[2]; pipe(pipe_master); ...

Function names extraction from static library.

Hi! I have a static library static_library.a How to list functions and methods realized there. or at least how to look is there concrete function 'FUNCTION_NAME' realized? ...

In terminal, merging multiple folders into one.

I have a backup directory created by WDBackup (western digital external HD backup util) that contains a directory for each day that it backed up and the incremental contents of just what was backed up. So the hierarchy looks like this: 20100101 My Documents Letter1.doc My Music Best Songs Every First Songs.mp3 My...

An old flaw in X Window System. How does it work?

I was going through an article today when it mentioned the following: "We've found many errors over the years. One of the absolute best was the following in the X Window System: if(getuid() != 0 && geteuid == 0) { ErrorF("Only root"); exit(1); } It allowed any local user to get root access. (The ...

What is difference between a job and a process in Unix ?

What is the difference between a job and a process in Unix ? Can you please give an example ? ...

C signal parent process from child

I'm trying to solve a problem I've got where a child process runs execvp() and needs to let the parent know if it returns. So, after the execvp() returns (because there's been an error), how can I tell the parent that this particular event has happened so it can handle it. There's one method of writing a string of text through the pipe ...

How to receive the text which was sent by SendText

In asterisk I have sent a text message using SendText as follows I have two registered users in sip.conf file. sip.conf details [thillai] username=thillai secret=thillai host=dynamic type=friend allow=all context=test [selvan] username=selvan secret=selvan allow=all host=dy...

percentage of memory used used by a process

percentage of memory used used by a process. normally prstat -J will give the memory of process image and RSS(resident set size) etc. how do i knowlist of processes with percentage of memory is used by a each process. i am working on solaris unix. addintionally ,what are the regular commands that you use for monitoring processes,perfo...

Percentage value with GNU Diff

What is a good method for using diff to show a percentage difference between two files? Such as if a file has 100 lines and a copy has 15 lines that have been changed the diff-percent would be 15%. ...

Is there a POSIX syscall to resolve file system paths?

Is there a POSIX syscall to resolve filesystem paths? I have the CWD for a path, as well as the path to a file from that CWD. I can't use chdir to switch to the directory because I need to resolve paths from multiple threads simultaneously. I considered appending a / in between the CWD and the path, but for some reason it feels like that...

Using ptrace to generate a stack dump

Hello. I am compiling C++ on *nix and I would like to generate a stack dump a) at an arbitrary point in the program, b) during any signal, particularly during SIGSEGV. Google tells me that ptrace is probably the tool for the job, but I can't find any comprehensible examples of walking the stack. Getting the return address, yeah, but wh...

Can I get the amount of time for which a key is pressed on a keyboard

Dear all, I am working on a project in which I have to develop bio-passwords based on user's keystroke style. Suppose a user types a password for 20 times, his keystrokes are recorded, like holdtime : time for which a particular key is pressed. digraph time : time it takes to press a different key. suppose a user types a password ...

New at Python: GLPK not building properly / Python ImportError

This is a beginner question, and a follow-up to this one, where I was pointed to GLPK. I'm trying to get PyGLPK, a Python binding for the GNU Linear Programming Kit up and running, but no matter what I do, I can't seem to build and install GLPK so that Python finds it correctly. This comes after running ./configure, make, and sudo make...

Is there a java library equivalent to file command in unix

Is there any java library that is similar to unix's command file? ie: $ file somepicture.png somepicture.png PNG image, 805 x 292, 8-bit/color RGB, non-interlaced The file command is such a nice tool. I need something that can tell me if the file is really what I want it to be. (ie a picture, document etc) I know I can run the comm...