Sponsored Content
Top Forums Shell Programming and Scripting Inquiry on Grabbing info from file. Post 302519338 by NelsonC on Tuesday 3rd of May 2011 05:43:00 PM
Old 05-03-2011
Inquiry on Grabbing info from file.

Here is another script I am trying to customize currently,

this script is used to send me disk space information, but at the moment I have to enter all the servers in manually SERVER= "xxx bbb ccc" ect..

how can I script it so that the servers are called off a txt file versus me entering all of them ? my intention is to separate them PROD, QA ect.. and call those txt files and environments when needed.

Like a plug and play.
Code:
#!/bin/bash
Date="'date +%m/%d/%y %H:%M:%S'"

SERVERS="xxx bbb ccc" 
USR="me"

# Email
SUBJECT="Disk Free Verification for Hosts"
EMAIL="xxx@ex"
EMAILMESSAGE="/u/home/xxx/AccountV.txt"

# create new file
>$EMAILMESSAGE

# connect each host and pull up user listing
for host in $SERVERS
do
echo "--------------------------------" >>$EMAILMESSAGE
echo "* HOST: $host " >>$EMAILMESSAGE
echo "--------------------------------" >>$EMAILMESSAGE
ssh $USR@$host df -h | sed '/platform/d' >> $EMAILMESSAGE
done

# send an email using /bin/mail
#/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE
mailx -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE


Last edited by Scott; 05-03-2011 at 07:27 PM.. Reason: Code tags
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script grabbing cvs file .....

how do I write a script to checkout a file in cvs and cat the file into a file in my home directory Commands are cd /home/smr/sandbox cvsroot choose option 1 cvs co filename cat filename > /home/smr/newfilename Thank you! (4 Replies)
Discussion started by: llsmr777
4 Replies

2. Shell Programming and Scripting

Sed grabbing the last line of a file

I can grab the first line w/ sed how do you grab the last line of a file? (2 Replies)
Discussion started by: xgringo
2 Replies

3. UNIX for Dummies Questions & Answers

Grabbing a value from an output file

I am executing a stored proc and sending the results in a log file. I then want to grab one result from the output parameters (bolded below, 2) so that I can store it in a variable which will then be called in another script. There are more details that get printed in the beginning of the log file,... (3 Replies)
Discussion started by: hern14
3 Replies

4. Shell Programming and Scripting

Grabbing info from Telnet

I have a process that is running locally on the machine. When you telnet to the process: telnet IP port, it automatically returns a string which shows the status of that process. Something like this: # telnet IP Port Trying 127.0.0.1... Connected to localhost (127.0.0.1). Escape... (3 Replies)
Discussion started by: skaptakalian
3 Replies

5. Shell Programming and Scripting

grabbing filename from text file....should be easy!

Quick question...I'm trying to grab the .tif file name from this output from our fax server. What is the best way i can do this in a bash script? I have been looking at regular expressions with bash or using awk but having some trouble. thanks! The only output i want is... (5 Replies)
Discussion started by: kuliksco
5 Replies

6. Shell Programming and Scripting

Kornshell grabbing value from file

I have a script right now that I run a command which outputs just one word to a file. Well I need to grab that value and use it in another line of code so... touch oraclesid.txt echo $ORACLE_SID > oraclesid.txt #grab that value sqlplus v500/v500@<value> how do I grab that value from the... (6 Replies)
Discussion started by: Blogger11
6 Replies

7. Cybersecurity

Inquiry of .awo hidden dir with bin file inside .eeesync extension

Hi, Me i ask if someone knows about this hidden directory or it me knows where this dir associated with or in a program. I had and notices this .awo dir with bin files inside title 6770669_info.eeesync files in my directory. I wonder if this is associated with my backup program or any program... (0 Replies)
Discussion started by: jao_madn
0 Replies

8. Shell Programming and Scripting

Grabbing the newest file, cleaner method?

Greetings, I'm doing a process whereby I need to search for all filenames containing a given bit of text and grab the newest file from what may be 20 results. In a script I'm writing, i've got a monster line to do the sort as follows: find /opt/work/reports/input -name "*$searchtarget*" |... (4 Replies)
Discussion started by: Karunamon
4 Replies

9. Shell Programming and Scripting

Grabbing a chunk of text from a file

Hi, I have a Report.txt file. Say the contents of this file are : 1 2 3 4 5 7 df v g gf e r dfkf lsdk dslsdklsdk Report Start: xxxxxxdad asdffsdfsdfsdfasfasdffasdf sadfasdfsadffsfsdf Report End. sdfasdfasdf sdfasfdasdfasdfasdfasdf sadfasdfsdf I need to grab from Report Start... (3 Replies)
Discussion started by: mrskittles99
3 Replies

10. Shell Programming and Scripting

Grabbing value from file and run command in ``

Hi ALL, How can I make a script take data from a file and execute the commands within `` in the file n put that that in a variable? for i in `cat file` do file=`grep -i key file` cp ${file} test done file /tmp/`date +y`log /tmp/unix`date +y`log (1 Reply)
Discussion started by: 3junior
1 Replies
HOST(1) 						      General Commands Manual							   HOST(1)

NAME
host - look up host names using domain server SYNOPSIS
host [-l] [-v] [-w] [-r] [-d] [-t querytype] [-a] host [ server ] DESCRIPTION
Host looks for information about Internet hosts. It gets this information from a set of interconnected servers that are spread across the country. By default, it simply converts between host names and Internet addresses. However with the -t or -a options, it can be used to find all of the information about this host that is maintained by the domain server. The arguments can be either host names or host numbers. The program first attempts to interpret them as host numbers. If this fails, it will treat them as host names. A host number consists of first decimal numbers separated by dots, e.g. 128.6.4.194 A host name consists of names separated by dots, e.g. topaz.rutgers.edu. Unless the name ends in a dot, the local domain is automatically tacked on the end. Thus a Rutgers user can say "host topaz", and it will actually look up "topaz.rutgers.edu". If this fails, the name is tried unchanged (in this case, "topaz"). This same convention is used for mail and other network utilities. The actual suffix to tack on the end is obtained by looking at the results of a "hostname" call, and using everything starting at the first dot. (See below for a description of how to cus- tomize the host name lookup.) The first argument is the host name you want to look up. If this is a number, an "inverse query" is done, i.e. the domain system looks in a separate set of databases used to convert numbers to names. The second argument is optional. It allows you to specify a particular server to query. If you don't specify this argument, the default server (normally the local machine) is used. If a name is specified, you may see output of three different kinds. Here is an example that shows all of them: % host sun4 sun4.rutgers.edu is a nickname for ATHOS.RUTGERS.EDU ATHOS.RUTGERS.EDU has address 128.6.5.46 ATHOS.RUTGERS.EDU has address 128.6.4.4 ATHOS.RUTGERS.EDU mail is handled by ARAMIS.RUTGERS.EDU The user has typed the command "host sun4". The first line indicates that the name "sun4.rutgers.edu" is actually a nickname. The offi- cial host name is "ATHOS.RUTGERS.EDU'. The next two lines show the address. If a system has more than one network interface, there will be a separate address for each. The last line indicates that ATHOS.RUTGERS.EDU does not receive its own mail. Mail for it is taken by ARAMIS.RUTGERS.EDU. There may be more than one such line, since some systems have more than one other system that will handle mail for them. Technically, every system that can receive mail is supposed to have an entry of this kind. If the system receives its own mail, there should be an entry the mentions the system itself, for example "XXX mail is handled by XXX". However many systems that receive their own mail do not bother to mention that fact. If a system has a "mail is handled by" entry, but no address, this indicates that it is not really part of the Internet, but a system that is on the network will forward mail to it. Systems on Usenet, Bitnet, and a number of other networks have entries of this kind. There are a number of options that can be used before the host name. Most of these options are meaningful only to the staff who have to maintain the domain database. The option -w causes host to wait forever for a response. Normally it will time out after around a minute. The option -v causes printout to be in a "verbose" format. This is the official domain master file format, which is documented in the man page for "named". Without this option, output still follows this format in general terms, but some attempt is made to make it more intel- ligible to normal users. Without -v, "a", "mx", and "cname" records are written out as "has address", "mail is handled by", and "is a nickname for", and TTL and class fields are not shown. The option -r causes recursion to be turned off in the request. This means that the name server will return only data it has in its own database. It will not ask other servers for more information. The option -d turns on debugging. Network transactions are shown in detail. The option -t allows you to specify a particular type of information to be looked up. The arguments are defined in the man page for "named". Currently supported types are a, ns, md, mf, cname, soa, mb, mg, mr, null, wks, ptr, hinfo, minfo, mx, uinfo, uid, gid, unspec, and the wildcard, which may be written as either "any" or "*". Types must be given in lower case. Note that the default is to look first for "a", and then "mx", except that if the verbose option is turned on, the default is only "a". The option -a (for "all") is equivalent to "-v -t any". The option -l causes a listing of a complete domain. E.g. host -l rutgers.edu will give a listing of all hosts in the rutgers.edu domain. The -t option is used to filter what information is presented, as you would expect. The default is address information, which also include PTR and NS records. The command host -l -v -t any rutgers.edu will give a complete download of the zone data for rutgers.edu, in the official master file format. (However the SOA record is listed twice, for arcane reasons.) NOTE: -l is implemented by doing a complete zone transfer and then filtering out the information the you have asked for. This command should be used only if it is absolutely necessary. CUSTOMIZING HOST NAME LOOKUP
In general, if the name supplied by the user does not have any dots in it, a default domain is appended to the end. This domain can be defined in /etc/resolv.conf, but is normally derived by taking the local hostname after its first dot. The user can override this, and specify a different default domain, using the environment variable LOCALDOMAIN. In addition, the user can supply his own abbreviations for host names. They should be in a file consisting of one line per abbreviation. Each line contains an abbreviation, a space, and then the full host name. This file must be pointed to by an environment variable HOSTALIASES, which is the name of the file. See Also named (8) BUGS
Unexpected effects can happen when you type a name that is not part of the local domain. Please always keep in mind the fact that the local domain name is tacked onto the end of every name, unless it ends in a dot. Only if this fails is the name used unchanged. The -l option only tries the first name server listed for the domain that you have requested. If this server is dead, you may need to specify a server manually. E.g. to get a listing of foo.edu, you could try "host -t ns foo.edu" to get a list of all the name servers for foo.edu, and then try "host -l foo.edu xxx" for all xxx on the list of name servers, until you find one that works. HOST(1)
All times are GMT -4. The time now is 04:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy