Sponsored Content
Top Forums Shell Programming and Scripting Need to create a simple script using MD5, SSH... Post 302503085 by Corona688 on Wednesday 9th of March 2011 04:11:03 PM
Old 03-09-2011
Okay, so we're feeding the output of /usr/local/bin/hosts into the loop like this:

Code:
/usr/local/bin/hosts | while read LINE
do
        echo "Got $LINE"
done

...but anything in the loop can read read from that, not just the 'while' bit. If you do this:
Code:
/usr/local/bin/hosts | while read LINE
do
        cat > /dev/null # Read and throw away the rest of the lines
        echo "Got $LINE"
done

...you get nothing but the first line.

I didn't expect the md5 command to read anything except the file it was given; that's not just the way md5sum works but the traditional way for UNIX commands to operate. Some read standard input when given no files, and some read standard input when told to read from -. I gave it a filename, and it read from the file, and when it finished that it read from the list, too! Throwing it all away and putting it into the checksum. I had to force it to read from /dev/null instead, which is a "special" file that always does nothing.

---------- Post updated at 03:11 PM ---------- Previous update was at 03:02 PM ----------

Quote:
Originally Posted by Chubler_XL
Think they all match because $TMP still has result from local hash or previous host
Sorry, but that's completely wrong. > always truncates the file, so the temp file was always completely replaced each time ssh was called. You could hardly expect your ">$TMP" to work if > didn't work that way! You have to use >> to append.

The defensive quoting is a good idea though.
 

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
HOSTS.NNTP(5)							File Formats Manual						     HOSTS.NNTP(5)

NAME
hosts.nntp, hosts.nntp.nolimit - list of hosts that feed NNTP news DESCRIPTION
The file /etc/news/hosts.nntp is read by innd(8) to get the list of hosts that feed the local site Usenet news using the NNTP protocol. The server reads this file at start-up or when directed to by ctlinnd(8). When a host connects to the NNTP port of the system on which innd is running, the server will do a check to see if their Internet address is the same as one of the hosts named in this file. If the host is not mentioned, then innd will spawn an nnrpd(8) to process the connection, with the accepted connection on standard input and stan- dard output. Comments begin with a number sign (``#'') and continue through the end of the line. Blank lines and comments also ignored. All other lines should consist of two or three fields separated by a colon. The first field should be either an Internet address in dotted-quad format or an address that can be parsed by gethostbyname(3). If a host's entry has multiple addresses, all of them will be added to the access list. The second field, which may be blank, is the password the foreign host is required to use when first connecting. The third field, which may be omitted, is a list of newsgroups to which the host may send articles. This list is parsed as a newsfeeds(5) subscription list; groups not in the list are ignored. Posts crossposted in groups matched by a @group.* entry are dropped. For example: ## FOO has a password, UUNET and VIX dont. ## UUNET cannot post to local groups. ## Example is not part of Usenet II. ## These are comment lines. news.foo.com:magic uunet.uu.net::!foo.* data.ramona.vix.com: newspeer.example.com::*,@net.* The first field may be suffixed by ``/s'' to indicate that streaming commands are specifically permitted to be used by this host. By default streaming commands are available to all hosts. If any entry in hosts.nntp has a ``/s'' suffix, then only those hosts with the ``/s'' suffix will be permitted to use streaming commands. For example, with the following hosts.nntp file, only the host data.ramona.vix.com is allowed to use the streaming commands. ## As above, but news.foo.com:magic uunet.uu.net::!foo.* data.ramona.vix.com/s: The first field may be suffixed by ``/a'' to indicate that the IP address of the feeding hosts allowed by this entry should always be included in the Path line of articles, or by ``/t'' to indicate that the address should not be included, or ``/a'' followed by a pathhost value to indicate that the IP address should be included if the most recent Path entry does not match the pathhost specified after ``/a''. The default is to log the address in articles whose most recent Path entry is not the same as the hostname in the hosts.nntp entry. Since innd is usually started at system boot time, the local nameserver may not be fully operational when innd parses this file. As a work-around, a ctlinnd ``reload'' command can be performed after a delay of an hour or so. It is also possible to provide both a host's name and its dotted-quad address in the file. If the file contains passwords, it should not be world-readable. The file /etc/news/hosts.nntp.nolimit, if it exists is read whenever the ``hosts.nntp'' file is read. It has the same format, although only the first field is used. Any host mentioned in this file is not sub- ject to the incoming connections limit specified by innd's ``-i'' flag. This can be used to allow local hosts or time-sensitive peers, to connect regardless of the local conditions. HISTORY
Written by Rich $alz <rsalz@uunet.uu.net> for InterNetNews. This is revision 1.22, dated 1996/11/27. SEE ALSO
ctlinnd(8), innd(8), nnrpd(8). HOSTS.NNTP(5)
All times are GMT -4. The time now is 09:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy