unix

BASH subshells and sudo?

Hello -- I'm writing a bash script that needs to sudo multiple commands. I can do this: ( whoami ; whoami ) but I can't do this: sudo ( whoami ; whoami ) How do I solve this? ...

How to change the default behavior of the [TAB] key while calling an application from the shell?

The default behavior for the [TAB] key in the shell is to automatically auto-complete or list the files in the current directory. How to override this behavior in the shell for some chosen applications? Edit: This is not related to the application that is being used, rather, it's the shell environment that needs to be customized! (Thank...

Comparing views in ClearCase

I have two dynamic views in ClearCase which, as far as I know, are supposed to be "equal". One is supposed to look at the "Main branch" and one at some other branch (let's call it A). I did a merge from A to Main (in the Main view) and for some reason the code at the A view compiles while Main does not. Is there a way to compare the v...

producer-consumer problem:posix mutex got locked twice when using condition variable?

Following code is only to show how to use condition variable to synchronize threads(one producer and many consumers) as exercising. See the line for code 'usleep(100);'.When I comment this line,two consumer threads seem got the mutex locked at the same time after the producer thread exit,and then wait on 'cond',this raise race condition...

Issue in periodically reading contents of stdout redirected to pipe using dup2

Hi, I have to periodically read contents of stdout which is redirected to file. please help me to resolve issue. My problem in detail is that i have two thread in first thread , i have to execute a c file which is continously writing output to stdout(i.e writing hello world in infinite loop) and in second thread i have to retrieve l...

shell scripting for token replacement in all files in a folder

HI I am not very good with linux shell scripting.I am trying following shell script to replace revision number token $rev -<rev number> in all html files under specified directory cd /home/myapp/test set repUpRev = "`svnversion`" echo $repUpRev grep -lr -e '\$rev -'.$repUpRev.'\$' *.html | xargs sed -i 's/'\$rev -'.$repUpRev.'\$'/'\...

Trigger a shell script on receiving an email

How can we trigger a shell script on an unix server through an email with particular subject? ...

how to make a special cron job?

hi, i need to make a cron job to run a java program every 40 minutes on unix server. considering that: 1)it should run from 8h30 to 12h30 and from 14h to 18h from monday to friday 2) take consideration of holidays. i've read a lot about it and found this */30 8..13,14..19 * * 1..5 as the closest solution. i wanna know if crontab can d...

How do I send multiple results from one command to another in bash?

Hey guys and gals, I'm not sure if this is possible in one line (i.e., without writing a script), but I want to run an ls | grep command and then for each result, pipe it to another command. To be specific, I've got a directory full of images and I only want to view certain ones. I can filter the images I'm interested in with ls | gr...

shell scripting default value

I am trying to learn shell scripting and I am kind of confused with the idea of := or default value #!/bin/sh echo "Please enter a number \c" read input input=$((input % 2)) if [ $input -eq 0 ] then echo "Th...

How to invoke another terminal for output programmatically in c in linux

Hello world. I'm kind of new to unix environment. I want to have a little chat program that the initial terminal is used for input, and invoke another terminal for output. I've been searching the web but without any luck. Hope I can get some clues here. Thanks. Ok, to be more specific, I am writing a chat program over tcp/ip on m...

How close are Mac OS X and BSD related?

I read that Mac OS X and bsd are related. How close are they related. Can Mac OS X software be tweaked and installed on BSD? ...

Is there an equivalent of less for SQL*Plus?

Sometimes a query on SQL*Plus might yield too many rows t fit on the screen. Is there some equivalent of "piping to less/more" mechanism that I can do to navigate the results? select * from emp | less ...

rsync , all files are shown as changed

I am trying to use rsync to take backup of a rapidly changing directory having over 100 files. every time it is trying to copy all the files.-i option gives all +'s on a file which is not modified at all. ls -l | grep shows same result on server and client. But rsync -inv... shows >f+++++++++ . Thanks, kaka ...

How to print a line with a pattern which is nearest to another line with a specific pattern?

I want to find a pattern which is nearest to a specific pattern. Such as I want to print "bbb=" which is under the "yyyy:" (it is the closest line with bbb= to yyyy). It is line 8. line numbers and the order might be changed so it is better not to use line numbers. root# vi a "a" 15 lines 1 ## xxxx: 2 aaa=3 3 bbb=4 4 ccc=2 ...

Python daemon will not run in background on Ubuntu

Hi, My python daemon runs fine in the foreground of my Ubuntu system using this command in the terminal: python /opt/my-daemon.py foreground However when I try to call the daemon using the "start" command it fails, why? python /opt/my-daemon.py start This is how I call the command in the /etc/rc.local file: python /opt/my-d...

Is it possible to create a script to save and restore permissions?

I am using a linux system and need to experiment with some permissions on a set of nested files and directories. I wonder if there is not some way to save the permissions for the files and directories, without saving the files themselves. In other words, I'd like to save the perms, edit some files, tweak some permissions, and then rest...

Does SQL*Plus natively allow queries to run from the shell itself?

For example, is there equivalent of these in SQL*Plus sqlplus 'SELECT * FROM emp' | less sqlplus 'SELECT * FROM emp' | grep Primx One way has been suggested by paxdiablo here. Is that the only way? ...

perl sort temporary directory

I ran into space issues on my machine and therefore the sort command in unix failed because of lack of space in /tmp. In order to circumvent this, I decided to run sort with the -T option allowing it to use some other directory for creating temporary files. here is the perl script I have my $TMPDIR = "/home/xyz/workspace...

how to stream data in unix

How to stream data to a remote server in unix? I do not want to do ssh. Currently what I am doing on local machine is: cat local_file | ssh root@remote_machine "cat >> remote_file" But this file is large and I want a lighter way than ssh. I do not care about security or ack. ...