Tag Archives: KEY

Script to run command one by one

By misterx12345

Hi,

I have run a lot of commands one after one,
but I can’t run them simultaneous.
One command has to run and when finished second command has to run.
Also I would like to save all the outputs created by the commands in a file.
The commands can sometimes take hours, so it is also necessary to run them in the background.
Every command is saved in a file.
I am running Solaris 10 with bash shell.
This is what I have found so far:

#! /bin/bash

function continue ()
{
echo -n “Continue? “
read KEY
}

echo “1st command”
continue
echo “2nd command”
continue
echo “3rd command”

exit 0

From: http://www.unix.com/shell-programming-scripting/221043-script-run-command-one-one.html

Bash For Loop Help

By zenyoul

This is a short program I wrote to search through a directory and move files containing the keyword to a folder.

Code:

#!/bin/bash

echo 'What is the directory?'
read DIR
echo -e 'n'

echo 'What is the keyword?'
read KEY

echo -e 'n'

cd $DIR
rmdir 'relevant_files'
mkdir 'relevant_files'

for entry in 'grep -ilr $KEY $DIR'; do
echo $entry
mv $entry 'relevant_files'
done


The main problem I’m having with is the for loop.

Code:

for entry in 'grep -il $KEY $DIR'; do
echo $entry
mv $entry 'relevant_files'
done


My question is, how would I make the for loop entries equal to each file grep comes up with in the directory?

…read more

Source: FULL ARTICLE at The UNIX and Linux Forums

Aaron Toponce: Create Your Own Graphical Web Of Trust- Updated

pubring-small

A couple years ago, I wrote about how you can create a graphical representation of your OpenPGP Web of Trust. It’s funny how I’ve been keeping mine up-to-date for these past couple years as I attend keysigning parties, without really thinking about what it looks like. Well, I recently returned from the SCaLE 11x conference, which had a PGP keysigning party. So, I’ve been keeping the graph up-to-date as new signatures would come in. Then it hit me: am I graphing ONLY the signatures on my key, or all the signatures in my public keyring, or something somewhere in between? It seemed to be the latter, so I decided to do something about it.

The following script assumes you have the signing-party, graphviz and imagemagick packages installed. It grabs only the signatures on your OpenPGP key, downloads any keys that have signed your key that you may not have downloaded, places them in their own public keyring, then uses that information to graph your Web of Trust. Here’s the script:

#!/bin/bash
# Replace $KEY with your own KEYID
KEY=“22EEE0488086060F”
echo “Getting initial list of signatures…”
gpg –with-colons –fast-list-mode –list-sigs $KEY | awk -F ‘:’ ‘$1 ~ /sig|rev/ {print $5}’ | sort -u > ${KEY}.ids
echo “Refreshing your keyring…”
gpg –recv-keys $(cat ${KEY}.ids) > /dev/null 2>&1
echo “Creating public keyring…”
gpg –export $(cat ${KEY}.ids) > ${KEY}.gpg
echo “Creating dot file…”
gpg –keyring ./${KEY}.gpg –no-default-keyring –list-sigs | sig2dot > ${KEY}.dot 2> ${KEY}.err
echo “Creating PostScript document…”
neato -Tps ${KEY}.dot > ${KEY}.ps
echo “Creating graphic…”
convert ${KEY}.ps ${KEY}.gif
echo “Finished.”

It may take some time to download and refresh your keyring, and it may take some time generating the .dot file. Don’t be surprised if it takes 5-10 minutes, or so. However, when it finishes, you should end up with something like what is below (it’s obvious when you’ve attended keysigning parties by the clusters of strength in your web):

Click for a larger version

…read more
Source: FULL ARTICLE at Planet Ubuntu

Change value in a textFile

By Xedrox

Hi everyone,

I need to make a script to take three parameters:

-> KEY
-> NEW_VALUE
-> FILE

The FILE is a text plane file.
The KEY is a variable to configure, for example:

Code:

KEY1 = HOLA
KEY2= HOLA
KEY3=HELLO
KEY4 =HOLA


And the NEW_VALUE is the string next to symbol “=”.

The script must change a value of a “KEY“. For example, supose i have the next file:

Code:

KEY1 = HOLA
KEY2 = HOLA
KEY3 =HELLO
KEY4 =HOLA


I execute the next comand: ./script ‘KEY2’ ‘BAZINGA’ ‘myFile.txt’

The result must be:

Code:

KEY1 = HOLA
KEY2 =BAZINGA
KEY3 =HELLO
KEY4 =HOLA


I did the next script:

Code:

CLAVE=$1
NEWVALUE=$2
ARCHIVO_DESTINO=$3

if [ ! -f $ARCHIVO_DESTINO ]
then
echo "ERROR EN CHANGE_VALUE_CONFIG, NO se encontro el archivo: $ARCHIVO_DESTINO"
exit 1
fi

awk -F= -v P1="$CLAVE" -v P2="$NEWVALUE" '$1==P1{$0=P2}1' $ARCHIVO_DESTINO > temporalConfig

rm $ARCHIVO_DESTINO
mv temporalConfig $ARCHIVO_DESTINO


The problem is: just works well, when there is not space between “KEY” and “=” and “VALUE”. For example “KEY1=HOLA”. I need to this work with the next format “KEY1 =HOLA”. How can i change my script?

Thanks!
Sorry for my english!

Source: FULL ARTICLE at The UNIX and Linux Forums

Average of columns with values of other column with same name

I have a lot of input files that have the following form:

Code:
Sample Cq Sample Cq Sample Cq Sample Cq Sample Cq
1WBIN 23.45 1WBIN 23.45 1CVSIN 23.96 1CVSIN 23.14 S1 31.37
1WBIN 23.53 1WBIN 23.53 1CVSIN 23.81 1CVSIN 23.24 S1 31.49
1WBIN 24.55 1WBIN 24.55 1CVSIN 23.86 1CVSIN 23.24 S1 31.74
1CVSIN 23.62 1CVSIN 23.62 1CVSIP 22.12 1CVSIP 21.53 S10 31.13
1CVSIN 23.46 1CVSIN 21.74 1CVSIP 22.24 1CVSIP 21.40 S10 31.10
ICVSIN 21.74 1CVSIN 23.33 1CVSIP 22.22 1CVSIP 21.36 S10 31.29

I need to read each column, get the row values from the column next to it that have same name in the first column and compute the average of their values and output in a new file. They are usually triplicates of the same name, i need to get all three of its values and compute the average of these . The output should look like this in a new file:

Code:
Sample Cq Sample Cq Sample Cq Sample Cq Sample Cq
1WBIN 23.843 1WBIN 23.84 1CVSIN 23.87 1CVSIN 23.20 S1 31.53
1CVSIN 22.94 1CVSIN 22.89 1CVSIP 22.19 1CVSIP 21.43 S10 31.17
I print only one of the triplicates and next to it the average of the three values that each of the triplicates had.
Is it possible to be done in awk? I am trying with perl.

With PERL:
I thought of converting the columns into rows, read each line and create a hash having as KEY each Sample name and adding the value of each triplicate every time i find the same name to its VALUE. At the end I will divide the value/3 and output the key->value in the output file.
To keep the records organised and in order I will read the input file again and print key->value from the hash for each line.

Is there an easier way to do this? Because with hashes I will lose the ordering of the columns in the file and it will get a bit messy I’m afraid.

Thank you for any input.
Source: The UNIX and Linux Forums