unix

Variables value gets lost in subshell

This bash script concatenates the names for jar files to a classpath (variable CP), in the while loop the value is correct but is lost in the subshell as descibed in this related question http://stackoverflow.com/questions/124167/bash-variable-scope #!/bin/bash CP="AAA" func() { ls -1 | while read JAR do ...

awk / gawk asorti() problem

Hello stack. I've got following problem with gawk's asorti function: gawk 'BEGIN{ \ a[1]=6; \ a[2]=7; \ a[3]=8; \ a[21]=9; \ a[123]=10; \ t=asorti(a, o); \ for (i=1; i<=t; i++) { \ print i,o[i]; \ } \ }' The result is: 1 1 2 123 3 2 4 21 5 3 So it's pretty clear awk, sorted indices in lexicographi...

Increasing throughput in a python script

I'm processing a list of thousands of domain names from a DNSBL through dig, creating a CSV of URLs and IPs. This is a very time-consuming process that can take several hours. My server's DNSBL updates every fifteen minutes. Is there a way I can increase throughput in my Python script to keep pace with the server's updates? Edit: the sc...

What are the essential things that a new ubuntu server should have installed, for development purposes?

sudo apt-get install build-essential What else? ...

Need some help with serialization

I am trying to write a program to serialize a linked list to a file without using any libraries. My problem is how to add or remove nodes to the serialized structure since I dont have next pointer ? Also how can I avoid fragmentation ? Thanks & Regards ...

In Amazon EC2, how do I make it run a python script when I "clone" that instance?

Suppose I have a script in /home/myuser/go.py How do I run that script, when a new instance is booted? (I'm used to using the point-and-click control panel Amazon has...) ...

NServiceBus 2.0 considerations when running on Mono and deployed to *nix

Is NServiceBus compatible with Mono? Are you / have you run NServiceBus on Mono? If so what issues did you run into? NServiceBus leverage's MSMQ by default. I know this can be swapped out for different transport technologies, so I would imagine an initial task may involve implementing a provided "IMessageQueue " interface (or somethi...

What transport technology is a viable alternative to MSMQ on Unix based system?

I am planning on experimenting with NServiceBus on Mono to be deployed on Unix based systems. NServiceBus leverage's MSMQ by default. This can be easilly swapped out for an alterntive transport technology. What I need to know is what are the alternatives to MSMQ on Unix based systems, and how to do they differ and what are the pros & c...

Test local user login data

I'm currently in the process of writing a CGI blog engine in C (fun project - don't hate! :) and I'd like to enable posting for every user that has a login on the machine the webserver is running on. What is the correct way to see if a supplied login and password match against the systems login data? Just to clarify, if I have a shell ...

Unescaping HTML entities (&#nnnn;) into plain UTF-8

Hello, We have HTML source files which contain special characters encoded as &#nnnn; like in the word: au&#223;ergew&#246;hnlich We would like to convert them into plain UTF-8: außergewöhnlich Is there any small tool to do that? ...

antiword shell command does not work correctly through PHP

I called antiword in the shell using putty and it worked fine. However, when i call it using shell_exec() it always gives empty string. Here is the code I used: $file="IS_BT_KLVZ_MSI_001.doc"; $content=shell_exec("/usr/local/bin/antiword /usr/local/apache/htdocs/dokuman_sorgusu/documents/$file"); var_dump($content); In one forum, I s...

perl fork doesn't work properly when run remotely (via ssh)

I have a perl script, script.pl which, when run, does a fork, the parent process outputs its pid to a file then exits while the child process outputs something to STOUT and then goes into a while loop. $pid = fork(); if ( ! defined $pid ) { die "Failed to fork."; } #Parent process elsif($pid) { if(!open (PID, ">>running_PIDs")...

How To Sort Tab Format File Based on Length of Column K

I have a space delimited tabular file that looks like this: >NODE 28 length 23 cov 11.043478 ACATCCCGTTACGGTGAGCCGAAAGACCTTATGTATTTTGTGG >NODE 32 length 21 cov 13.857142 ACAGATGTCATGAAGAGGGCATAGGCGTTATCCTTGACTGG >NODE 33 length 28 cov 14.035714 TAGGCGTTATCCTTGACTGGGTTCCTGCCCACTTCCCGAAGGACGCAC How can I use Unix sort to sort it by leng...

How to make AWK use the variable created in Bash Script

I have script that looks like this #!/bin/bash #exampel inputfile is "myfile.txt" inputfile=$1 basen=`basename $inputfile .txt` # create basename cat $inputfile | awk '{print $basen "\t" $3} # this doesn't print "myfile" but the whole content of it. What I want to do above is to print out in AWK the variable called 'basen' created...

Why can't I use Unix Nohup with Bash For-loop?

For example this line fails: $ nohup for i in mydir/*.fasta; do ./myscript.sh "$i"; done > output.txt& -bash: syntax error near unexpected token `do What's the right way to do it? ...

InputB vs. Get; code pages; slow reading on unix server

Hi, We have been using the usual code to read in a complete file into a string to then parse in VB6. The files are ANSI text but encoded using whatever code page the user was in at the time (we have Chinese and English users for example). This is the code Open FileName For Binary As nFileUnit sContents = StrConv(InputB(LOF(nFileUnit), ...

Shell Scripting - check java bin

On a unix machine, how can I write a shell script for checking if 'java bin' directory has been included in $PATH env. variable? ...

queque system that manages load

I need a queque system that runs as fast as possible but doesn't slow down the server. I have a web app (php) that converts different pieces of media (photos,video,etc). When someone wants to convert a file the command to convert goes into a database. I need a program that can run the commands in a way that will not crash my server. I...

Removing Parts of String With Sed

I have lines of data that looks like this: sp_A0A342_ATPB_COFAR_6_+_contigs_full.fasta sp_A0A342_ATPB_COFAR_9_-_contigs_full.fasta sp_A0A373_RK16_COFAR_10_-_contigs_full.fasta sp_A0A373_RK16_COFAR_8_+_contigs_full.fasta sp_A0A4W3_SPEA_GEOSL_15_-_contigs_full.fasta How can I use sed to delete parts of string after 4th column (_ separat...

Find files created in a particular ssh session or date

How can I find all the files that were created by a particular session using ssh? Or search for files that were created/modified on a particular date? ...