unix

Set environment variables using SSH

Hello, I am trying to execute unix command using SSH from cygwin. My set of command would navigate to a certain directory, source a particular file. Based on the variables sourced from that file, I would try to launch application. But somehow the variables are not getting sourced as echo does not return any values. Could someone let me ...

How to Compile the .cshsc File in Unix ?

Hi Everyone, I am new in Unix I m doing some changes in .cshsc file, It is shell script which is hidden So how can i compile this file Can anyone help me for that Or Give some idea ? Thanks in advance!! Riddhi ...

Why doesn't bash's flock with timeout exit if it fails to acquire the lock?

I am playing with using flock, a bash command for file locks to prevent two different instances of the code from running more than once. I am using this testing code: ( ( flock -x 200 ; sleep 10 ; echo "original finished" ; ) 200>./test.lock ) & ( sleep 2 ; ( flock -x -w 2 200 ; echo "a finished" ) 200>./test.lock ) & I am running 2...

Socket read() hangs for a while when there is no data to read.

Hi' I'm writing a simple http port forwarder. I read data from port 80, and pass the data to my lighttpd server, on port 8080. As long as I write() data on the socket on port 8080 (forwarding the request) there's no problem, but when I read() data from that socket (forwarding the response), the last read() hangs a lot (about 1 or 2 seco...

Interactive GUI-like command line merging tool (like BeyondCompare or WinMerge) for Linux

May be something that uses reverse-video to show the differences. ...

iteratively creating graphs

I have a bunch of files containing x and y coordinates, representing time and value (space-separated, but can be amended) For example, in each file I will have this sort of points: 15:06:59 0.0140 15:07:00 0.0142 ...etc.... I want to create a word file (or some equivalent) to show all these graphs. Currently, I am using Exc...

Strategy for handling user input as files

I'm creating a script to process files provided to us by our users. Everything happens within the same UNIX system (running on Solaris 10) Right now our design is this User places file into upload directory Script placed on cron to run every 10 minutes. Script looks for files in upload directory, processes them, deletes immediately af...

UNIX Parse HTML Page Display Contents of a Tag - One Liner?

I have an HTML file and I am interested in the data enclosed by <pre> </pre> tags. Is there a one-liner that can do achieve this? Sample file : <html> <title> Hello There! </title> <body> <pre> John Working Kathy Working Mary Working Kim N/A </pre> </body> </html> Output should be : John Kathy Mary Kim Much appreciat...

How can I map UIDs to user names using Perl library functions?

I'm looking for a way of mapping a uid (unique number representing a system user) to a user name using Perl. Please don't suggest greping /etc/passwd :) Edit As a clarification, I wasn't looking for a solution that involved reading /etc/passwd explicitly. I realize that under the hood any solution would end up doing this, but I was se...

Is Apache blocking I/O?

I am not familiar with internals of Apache so I am just wondering if Apache is blocking I/O or non-blocking IO? ...

Extract Lines when Column K is empty with AWK/Perl

I have data that looks like this: foo 78 xxx bar yyy qux 99 zzz xuq xyz They are tab delimited. How can I extract lines where column 2 is empty, yielding bar yyy xuq xyz I tried this but doesn't seem to work: awk '$2==""' myfile.txt ...

tool to find out distance in terms of no. of hops in unix

Hi! all, I am writing an application for video streaming.In the application server is required to know the distance of the client from it self in terms of hop number.My question is,is there any tool/method other than traceroute available in unix environment to find it? I also need to find out the geographical location of the client.So is...

Unix: command for sudo-mv-chown combo?

I am operating as sudo in a system where I mv a great amount of files and dirs to and fro. Is there a command for the combo? $ sudo -i; # mv hello /home/other; # chown -R other:other /home/other/hello ...

Read from unix pipe when there's no one to write to it. (C++)

If I spawn a child and pass him a pipe, the child writes to the output of the pipe(to the parent) and after that the child dies. Can the parent read from the pipe what the child had written before it died? Thanks. (ps: I'm talking about C++) ...

dd Command - How to determine cbs

I have a input file in EBCDIC format. I have no idea how many records there are in the file. In that case, if I want to convert it to ASCII, what would be ibs, obs, and cbs? ...

Utility that helps in file locking - expert tips wanted

I've written a subclass of file that a) provides methods to conveniently lock it (using fcntl, so it only supports unix, which is however OK for me atm) and b) when reading or writing asserts that the file is appropriately locked. Now I'm not an expert at such stuff (I've just read one paper [de] about it) and would appreciate some fee...

Find Directories With No Files in Unix/Linux

I have a list of directories /home /dir1 /dir2 ... /dir100 Some of them have no files in it. How can I use Unix find to do it? I tried find . -name "*" -type d -size 0 Doesn't seem to work. ...

Analog of COM programming in Linux/UNIX

The Component Object Model (COM) is (or was...) the way in Windows to provide language-neutral software components. Is there any programming model in Linux/UNIX with the same philosophy of code reuse through binary components? ...

Symlinking folders in bash

I want a folder /public_html to symlink to /current/app/webroot, both are in the same directory I have tried ln -s public_html current/app/webroot amongst other things, but no joy so far. Any ideas? ...

UNIX: Replace Newline w/ Colon, Preserving Newline Before EOF

I have a text file ("INPUT.txt") of the format: A<LF> B<LF> C<LF> D<LF> X<LF> Y<LF> Z<LF> <EOF> which I need to reformat to: A:B:C:D:X:Y:Z<LF> <EOF> I know you can do this with 'sed'. There's a billion google hits for doing this with 'sed'. But I'm trying to emphasis readability, simplicity, and using the correct tool for the corre...