unix

Keyboard input: how to separate keycodes received from user

Hello, I am writing an application involving user input from the keyboard. For doing it I use this way of reading the input: #include <stdio.h> #include <termios.h> #include <unistd.h> int mygetch( ) { struct termios oldt, newt; int ch; tcgetattr( STDIN_FILENO, &oldt ); newt = oldt; newt.c_lflag &...

How to use parallel execution in a shell script?

I have a C shell script that does something like this: #!/bin/csh gcc example.c -o ex gcc combine.c -o combine ex file1 r1 <-- 1 ex file2 r2 <-- 2 ex file3 r3 <-- 3 #... many more like the above combine r1 r2 r3 final \rm r1 r2 r3 Is there some way I can make lines 1, 2 and 3 run in parallel instead of one after the anothe...

Double paging definition

This is not a programming question but more of an operating system question Right now I'm trying to learn what exactly Double paging means. I see two different terms, double paging on disk and double paging in memory. Apparently this problem arises when we introduce a buffer cache to store disk blocks when doing File I/O But I'm not ...

Generate a random filename in unix shell

Hello, I would like to generate a random filename in unix shell (say tcshell). The filename should consist of random 32 hex letters, e.g.: c7fdfc8f409c548a10a0a89a791417c5 (to which I will add whatever is neccesary). The point is being able to do it only in shell without resorting to a program. ...

Passing partial arguments in tcshell

Hey, I'm writing a shell script (tcsh) that is supposed to received 3 parameters or more. The first 3 are to be passed to a program, and the rest are supposed to be passed to another program. All in all the script should look something like: ./first_program $1 $2 $3 ./second program [fourth or more] The problem is that I don't know ...

what does '-' stand for in bash?

Hi, What exactly are the uses of '-' in bash? I know they can be used for 1. cd - # to take you to the old 'present working directory' 2. some stream generating command | vim - # somehow vim gets the text. My question is what exactly is - in bash? In what other contexts can I use it? Regards Arun ...

how to add a function to that program, and call that function from the command line in the function

I have to add a custom function which shows currently running foreground and background processes launched by this shell. How do I define and call that function from the shell's command line? a#include "smallsh.h" /*include file for example*/ /*program buffers and work pointers*/ static char inpbuf[MAXBUF], tokbuf[2*MAXBUF], *ptr ...

Can't get websrvmng to run in Plesk SSH terminal.

I am following this MediaTemple KB article and stuck at the last step. When I try to run the websrvmng (using the ssh terminal in Plesk) using the code the KB references: /usr/local/psa/admin/sbin/websrvmng -v -a I receive a 'File or Directory not found' error. I am a n00b when it comes to this stuff and would really appreciate any ad...

What the best multi-thread application debugger for C++ apps.

I'm looking for a good multi-thread-aware debugger, capable of showing performance charts of application threads on Linux, don't know if such a thing exists, perhaps as a Eclipse plugin. The idea would be to track per thread memory allocation a CPU usage as well as being able to interrupt a thread and examine its stack trace, local vars,...

How do I pass a Python Variable to Bash?

Hello, How would I pass a Python variable to the Bash shell? It should work like this: foo="./RetVar.py 42" Replace the double-quotes with `s I have tried printing and sys.exiting the result, but to no avail. How would I accomplish my goal? ...

Search and replace

Hi, I have a really large SQL dump around 400MB. It's in the following format, "INSERT INTO user VALUES('USERID', 'USERNAME', 'PASSWORD', '0', '0', 'EMAIL', 'GENDER', 'BIRTHDAY', '182', '13', '640', 'Married', 'Straight', '', 'Yes', 'Yes', '1146411153', '1216452123', '1149440844', '0', picture', '1', '0', '0', 'zip', '0', '', '0', '',...

Perl -check for uninitialized value

I am doing the below in a perl script: my @pm1_CS_missing_months = `sqlplus -s $connstr \@DLmissing_months.sql`; it takes the output of an sql query. if i have to check for no rows selected,how could i do it? i want to do like this: if(no rows selected) { do this; } ...

How can I return a value from a Perl program to a Korn-shell script?

I want to do this in a shell script: #!/usr/bin/ksh PERL_PATH=/usr/local/bin/perl RET1=$(${PERL_PATH} missing_months_wrap.pl) echo $RET1 How do i do it? calling the perl script as above is giving me an error: > shell.sh Can't return outside a subroutine at missing_months_wrap.pl line 269. EDIT: inside the perl script the state...

searching multiple strings in a single file

I want to find the lines in which atleast one of the strings among string1 and string2 are present in the file. grep 'string1' 'string2' file;-this is an error even though!! how could i do the above on unix command line? ...

How to "signal" interested child processes (without signals)?

I'm trying to find a good and simple method to signal child processes (created through SocketServer with ForkingMixIn) from the parent process. While Unix signals could be used, I want to avoid them since only children who are interested should receive the signal, and it would be overkill and complicated to require some kind of registra...

Tab Delimited to Comma Separated file in UNIX - One liner?

I have a tab delimited file (MySQL Out file). I want to convert it into CSV file. I got everything working except for replacing NULLs to nothing or spaces. What I have is : sed -e 's/^/"/; s/$/"/; s/\t/","/g;' < file.csv > file1.csv How to also replace NULLs in the same line. The following doesn't work. sed -e 's/NULL//; s/^/"/; s/$...

Hard link and Symbolic links in Unix

Hi All, I just wanted to clarify if a hard/symbolic link is actually a file that is created ?? I ran the command: ln source hardlink ln -s source softlink -- The ls command shows this 2 links as a file. So my query is, does ln / ln -s actually create a file? Regards, darkie15 ...

sendto on Tru64 is returning ENOBUF

Hi, I am currently running an old system on Tru64 which involves lots of UDP sockets using the sendto() function. The sockets are used in our code to send messages to/from various processes and then eventually on to a thick client app that is connected remotely. Occasionally the socket to the thick client gets stuck, this can cause so...

How to do parrallel processing in Unix Shell script?

I have a shell script that transfers a build.xml file to a remote unix machine (devrsp02) and executes the ANT task wldeploy on that machine (devrsp02). Now, this wldeploy task takes around 15 minutes to complete and while this is running, the last line at the unix console is - "task {some digit} initialized". Once this task is co...

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 ...