Sponsored Content
Top Forums Shell Programming and Scripting Need to create a simple script using MD5, SSH... Post 302503054 by zixzix01 on Wednesday 9th of March 2011 02:56:08 PM
Old 03-09-2011
Sorry about thatthe box names are just first three initals of company with standard developers names

like:

xxxbox1
xxxbox2
xxxbox3

THe xxxbox1 one is our push server. From there we check all the rest!

Here is the output of the last code:
Code:
while read fname; do 
    bname=$(basename $fname) 
    echo "trying ${fname} (${bname})" >&2

    hash=$(/usr/local/bin/md5 "$fname" | awk '{print $4}')

    echo "local hash is ${hash}"

    # should just print the md5's
    /usr/local/bin/hosts | while read box
    do
        echo "${box}"
        # should print md5's repeatedly
        ssh ${box} "/usr/local/bin/md5" "$fname"
    done
done < /home/izivanov/iz3

And what the output is:

Quote:
xxxbox1(root):/home/izivanov# sh dirsync6.sh
trying /opt/dba/scp/xxxxxxxxxxxxx
local hash is xxxxxxxxxxxxxxxxxxxxxxx

~
~
~
local hash is xxxxxxxxxxxxxxxxxx
xxxbox3 /opt/dba/bin/xxxxxxxxxxxxxx differs!
We got a differ on one of the servers! Yeah something is definitely off! What do you need to see to have a better understanding!?

BTW we don't have md5sum ( we have md5), its an HP-UX environment. Isn't that only on the Linux type systems!?

---------- Post updated at 02:47 PM ---------- Previous update was at 02:44 PM ----------

did you get my message about what the host and hostname files look like and their output?

---------- Post updated at 02:56 PM ---------- Previous update was at 02:47 PM ----------

sorry the last code i actually used was:
Code:
#!/usr/bin/sh

# If you don't have mktemp, TMP=/tmp/$$ will do.  mktemp is more secure.
TMP=`mktemp`
while read fname; do
    #bname=$(basename $fname)
    echo "trying ${fname}" >&2

    if ! /usr/local/bin/md5 "$fname" > "$TMP" </dev/null
    then
        echo "md5 on ${bname} failed: "
        # print the error
        cat "$TMP"
        continue
    fi

    hash=$(awk '{print $4}' "$TMP")

    echo "local hash is ${hash}" >&2

    # should just print the md5's
    /usr/local/bin/hosts | while read box
    do
        # redirect its stdin to prevent it reading any filenames
        ssh "${box}" "/usr/local/bin/md5" "${fname}" > "$TMP" </dev/null

The only thing I added was #!/usr/bin/sh, cause my boss told me I would need it!

Last edited by zixzix01; 03-09-2011 at 06:06 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to create md5 Hash variable?

I have a script that runs the grub-md5-crypt command based on whether the pass_value variable is a non-zero string. The md5 hash is being created in the /opt/hostconfigs/$HOST file, but I can't echo $md5_value. It is blank. Is there a way to create and echo a md5 hash variable? if then... (1 Reply)
Discussion started by: cstovall
1 Replies

2. Shell Programming and Scripting

Modifying simple commands to create a script

Can anyone direct me to a resource that explains scripting in simple terms? I have visited many sites and browsed this forum and have yet to find simple explanations. (8 Replies)
Discussion started by: rocinante
8 Replies

3. Shell Programming and Scripting

Simple Script to create folders

Hi I want to write a small script that will create folders named from `AAAA' all the way to `ZZZZ'. That is: `AAAA' `AAAB' `AAAC' ... `AABA' `AABB' `AABC' ... `ABAA' `ABAB' `ABAC' ... `ABBA' ... `ZZZZ' (4 Replies)
Discussion started by: ksk
4 Replies

4. Shell Programming and Scripting

Simple SSH script

I have several unix servers, I need to logon to each server and find out if an id exists on that server. I need a simple script for this, i have come up with the following script, but I cannot bring the output of a child process on the remote server. for i in `cat SERVER_LIST` do ssh $i... (5 Replies)
Discussion started by: ramky79
5 Replies

5. Solaris

How to create a simple background script on Solaris

I have a local account for a unix server. The idle timeout for the account is around 10 mins. I have to login to the server multiple times during the day. Is there a way to increase the idle timeout or may be a script that I can run on background so it is not idle. Something like echo date every 9... (3 Replies)
Discussion started by: vinaysa
3 Replies

6. Shell Programming and Scripting

How to create a simple shell script to backup

Hello - I am in process of deleting many files which are older than 4 weeks. For example I am inside: /subsystem/prod/ Files are with various extentions, but anything older than 4 weeks should be deleted. What would be the most simplest script to acheive this? (4 Replies)
Discussion started by: DallasT
4 Replies

7. Shell Programming and Scripting

Create md5 sums and archive the resulting md5 files

Hello everyone, I am looking to basically creating md5sum files for all iso files in a directory and archive the resulting md5 files into a single archive in that very same directory. I worked out a clumsy solution such as: #find files for which md5sum are to be created and store the... (1 Reply)
Discussion started by: SurfTranquille
1 Replies

8. Shell Programming and Scripting

How to create a simple copy script?

Guys I want to do this: copy: /var/router/system1/config/backup/install.put /var/router/system2/config/backup/install.put /var/router/system3/config/backup/install.put /var/router/system4/config/backup/install.put into: /var/router/system1/config/install.dat... (22 Replies)
Discussion started by: DallasT
22 Replies

9. Shell Programming and Scripting

Create simple script

Dear all, I have a directory named A and some subdirectories named B, C, D with .xml files. I want to use the following command to strip the file. sed -re ':start s/<*>//g; /</ {N; b start}' file.xml > file.xml At the same time, I want to remove the blank lines using sed '/^$/d' How can... (6 Replies)
Discussion started by: corfuitl
6 Replies

10. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies
clm residue(1)							  USER COMMANDS 						    clm residue(1)

  NAME
      clm residue - extend clustering of subgraph to clustering of graph.

      clmresidue  is  not  in  actual fact a program. This manual page documents the behaviour and options of the clm program when invoked in mode
      residue. The options -h, --apropos, --version, -set, --nop are accessible in all clm modes. They are described in the clm manual page.

  SYNOPSIS
      clm residue -icl fname (input clustering) -imx fname (input graph) [-rpm fname (residue projection matrix)]  [-o	fname  (output	clustering
      file)]

  DESCRIPTION
      The cluster file presumably contains a clustering of a subgraph of the graph G contained by the matrix file, implying that the row domain of
      that clustering is a subset of the node domain of the graph. clm residue will compute  a	simple	upwards  projection  of  that  clustering,
      resulting in a clustering of G.

  OPTIONS
      -imx fname (input graph)

      -icl fname (input clustering)

      -rpm fname (residue projection matrix)
	The name for the file in which the residue projection matrix is stored.  It contains for each node and for each cluster in the input clus-
	tering the combined weight of the (edges to the) neighbours of that node in that cluster.  The default output file name is out.rpm.

      -o fname (output clustering file)
	The name for the file in which the majority vote projection clustering is stored. Aka the majority vote projection clustering storage file
	name.

	This  embodies	a very crude approach to distributing the missing nodes in the input clustering onto that same cluster. For each node, the
	cluster is taken for which the residue projection is the largest (see above). The residue (i.e. the set of  missing  nodes)  is  initially
	viewed	as  a  cluster;  the set of nodes for which the projection is largest for the residue itself will form a new cluster, if it is not
	empty.

	By default output is sent to STDOUT.

  AUTHOR
      Stijn van Dongen.

  SEE ALSO
      mclfamily(7) for an overview of all the documentation and the utilities in the mcl family.

  clm residue 12-068						      8 Mar 2012						      clm residue(1)
All times are GMT -4. The time now is 04:40 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy