Sponsored Content
Top Forums Shell Programming and Scripting Store Host lookup in variable ("on the fly") Post 302477243 by sOliver on Friday 3rd of December 2010 06:28:44 PM
Old 12-03-2010
Store Host lookup in variable ("on the fly")

Hi,

I'm new here. I was wondering why I can't store a host lookup in a variable.


Code:
for line in $(< blacklist)
do
STOREIP=host $line;
if [[ $storeip != *bot* ]]; then
$line >> blacklist2;
else
$line >> blacklist3;
fi
done

Result: "ip" command not found .. so how would I store the host lookup in the variable?

Basically I have IP's stored in a file and want to check them via rdns if they include the string "bot". If they dont I want to save them in blacklist2, if they do in blacklist3.

If anyone could help me out with this I'd be grateful... I'm pretty new to this and so far I really like how easy it is to write some useful scripts, but this is a bit too difficult for me.

Thanks a lot!
Oliver
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

How to store the output of "time dd if= of=" in a variable

Hi All, I need to store the real seconds of the following command in a variable. How could it be done? time $(dd if=/dev/zero of=/dev/sda1 bs=512 count=2048;sync) Thanks, Amio (12 Replies)
Discussion started by: amio
12 Replies

3. Shell Programming and Scripting

store the output of "find" command in a variable?

I intend to find the path/full location of a file(filename given by user thru "read filenme") using "find" or any other command and then store it's output in a variable for some other processing. But struggling to put all things together (i.e finding the fully qualified location of that file and... (4 Replies)
Discussion started by: punitpa
4 Replies

4. Shell Programming and Scripting

Unable to store "-e" in variable ??????

p="-e" echo $p It is not returning the value "-e" stored. Instead returns null. I am wondering how could this happen. Please help me out.I tried all possibilities like p='-e' | p="\-e". Nothing seems to work. :confused::confused: (10 Replies)
Discussion started by: shanneykar
10 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. UNIX for Advanced & Expert Users

How to gzip files "on fly" before copying

Hello, I want to gzip some files before copying to remote host. There is no freespace on source host so it needs to be perfomed within one-liner. I tried the following but it didn't work gzip -c -9 all_rvds.xml |ssh targethost "dd of=/tmp/all_rvds.xml.gz" cat all_rvds.xml |gzip -c9 |ssh... (5 Replies)
Discussion started by: urello
5 Replies

7. UNIX for Dummies Questions & Answers

What is the significance of sh -s in ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh?

Please can you help me understand the significance of providing arguments under sh -s in > ssh -qtt ${user}@${host} "sh -s "${version}"" < test.sh (4 Replies)
Discussion started by: Sree10
4 Replies

8. Shell Programming and Scripting

Unable to store "python --version" to a shell variable

Hi All, I need to get the version of python installed and store it in a variable for later use. Whereas it is printing on the console instead of storing to variable. I am able to store output of ls command in a variable. Please check the below code : root@myhost:/volumes/srini# cat... (4 Replies)
Discussion started by: srinivasan.neel
4 Replies

9. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
ARES_GETHOSTBYNAME(3)					     Library Functions Manual					     ARES_GETHOSTBYNAME(3)

NAME
ares_gethostbyname_file - Lookup a name in the system's hosts file SYNOPSIS
#include <ares.h> int ares_gethostbyname_file(ares_channel channel, const char *name, int family, struct hostent **host) DESCRIPTION
The ares_gethostbyname_file function performs a host lookup by name against the system's hosts file (or equivalent local hostname data- base). The channel parameter is required, but no asynchronous queries are performed. Instead, the lookup is done via the same mechanism used to perform 'f' lookups (see the lookups options field in ares_init_options(3)). The parameter name gives the hostname as a NUL-termi- nated C string, and family gives the desired type of address for the resulting host entry. The return value indicates whether the query succeeded and, if not, how it failed. It may have any of the following values: ARES_SUCCESS The host lookup completed successfully and host now points to the result (and must be freed with ares_free_hostent(3)). ARES_ENOTFOUND The hostname name was not found. ARES_EFILE There was a file I/O error while performing the lookup. ARES_ENOMEM Memory was exhausted. On successful completion of the query, the pointer pointed to by host points to a struct hostent containing the address of the host returned by the lookup. The user must free the memory pointed to by host when finished with it by calling ares_free_hostent(3). If the lookup did not complete successfully, host will be NULL. AVAILABILITY
Added in c-ares 1.5.4 SEE ALSO
ares_gethostbyname(3), ares_free_hostent(3), ares_init_options(3) AUTHOR
Brad Spencer Copyright 1998 by the Massachusetts Institute of Technology. 25 July 1998 ARES_GETHOSTBYNAME(3)
All times are GMT -4. The time now is 04:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy