Sponsored Content
Full Discussion: Scripting issue
Top Forums Shell Programming and Scripting Scripting issue Post 303005334 by rbatte1 on Tuesday 17th of October 2017 07:13:25 AM
Old 10-17-2017
Welcome arun_adm

I think your so-called one-liner is not. It is multiple commands (one of them over-complex) joined on a single line, making it hard to read.

Here it is written more sensibly (with a few tweaks too):-
Code:
while read target_server
do
   echo "+++++++++ ${target_server} +++++++++"
   ssh -q ${target_server} 'paste \
         <(/sbin/ifconfig -a|egrep -i "eth|bond"|awk '{print $1}') \
         <(/sbin/ifconfig -a|egrep "inet addr"|grep -v "127.0.0.1"|awk '{print $2}'|cut -d ':' -f 2) \
         <(/sbin/ifconfig -a|egrep "inet addr"|grep -v "127.0.0.1"|awk '{print $2}'|cut -d ':' -f 2| \
            xargs -n1 nslookup | grep -v nameserver | cut -f 2 | grep name | cut -f 2 -d "=" | sed 's/ //')'
   echo "========================="
done < server-list.txt > output.txt

I have used a meaningful variable name rather than just i and read the file into a while loop. It is clearer to read and the input does not risk get eaten up by the commands within the loop.

The line ending \ can have nothing after it. It means that the new-line is ignored, so on execution it is joined up but means it is somewhat easier to read.

I would suggest you are trying to do too much in one step with pipes from the output to grep, then awk, then cut, then xargs, then cut, then cut, then grep, then cut and finally sed Smilie

A tool like awk can do all of this (although it might need to call out to nslookup) which will neaten your code too.


Can you explain what you are actually trying to achieve? I think I've got it, but if I have misinterpreted, I don't want to write it out and have you think that I've got it.



Thanks, in advance,
Robin

Last edited by rbatte1; 10-17-2017 at 08:14 AM.. Reason: Added welcome
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

scripting issue

folks; i'm trying to write a shell script to do the following: 1. i have a file with 39 fields, i'm trying to add 10 more fields with (!) as a field separator. with the following requirement: if field number 20 has a value, then field number 40 will show as (!M!), and if the field number 20 does... (2 Replies)
Discussion started by: moe2266
2 Replies

2. Shell Programming and Scripting

Scripting issue..

Hi guys... I am a newbie to scripting... I have a small requirement... I dont whether u r clear with my requirement... But plz try to help me... Like, tell me some kind of scripts that can help me in retreiving the data from the datasets. Regards, Mahesh... (1 Reply)
Discussion started by: mraghunandanan
1 Replies

3. Shell Programming and Scripting

Scripting issue..

Hi guys... I am newbie to Shell Scripting... I am querying the Oracle database.I want a Shell script for fetching some data from datasets in Oracle database and displaying in an excel sheet.This is my requirement.. Can u plz help me guys.. Regards, Mahesh... (4 Replies)
Discussion started by: mraghunandanan
4 Replies

4. Shell Programming and Scripting

IP-Scripting Issue

Hi Guys, I am quite new to Shell Scripting... I need ur help.. This is very urgent. The thing is like, I need to match a IP address (ex 192.168.200.56) i.e, xxx.xxx.xxx.xx inside a KSH script,but if we enter in different format other than the specified format (ex jjj.ksj., 1.0...), it should... (3 Replies)
Discussion started by: mraghunandanan
3 Replies

5. Shell Programming and Scripting

scripting issue

Hello, Guys I am having a sql script file which contains some sql statements including inserting values, One column is of the data type date. Now i am having a KSH script for inserting values via this script into the database. The problem I am facing that when I am inserting value in the... (1 Reply)
Discussion started by: mraghunandanan
1 Replies

6. Shell Programming and Scripting

Scripting issue

Hello, I have an ASCII file (many files of the same format, but different dates and numbers) in the format like below: 2008.01.02,08:00,1.46520,1.46520,1.46410,1.46440,70 2008.01.02,08:05,1.46450,1.46560,1.46440,1.46540,79 2008.01.02,08:10,1.46530,1.46540,1.46490,1.46500,46... (8 Replies)
Discussion started by: chief2000
8 Replies

7. Shell Programming and Scripting

Scripting Issue

I am having an issue with a script that I created today, my first attempt at this, and was wondering if anyone can give me insight to what changes need to be made. Below is a copy of the script that I have written. WEe are trying to monitor whether or not a services is running. I do have a cron... (1 Reply)
Discussion started by: lsudubee
1 Replies

8. Shell Programming and Scripting

Scripting Issue

needing this script to shut down 1 IceS and start up another, close the 2nd one after 12 seconds and then reboot. here is what i have so far #!/bin/bash ShutDown() { echo "Shutdown in progress." wall <<ENDOFWALL CI Shutdown has been intiated!!!! Shutdown will occur in 30 seconds...... (1 Reply)
Discussion started by: Zaine
1 Replies

9. Shell Programming and Scripting

Scripting issue

I am having a problem. which I have described below>> I have to run a script with the format : <File_name><Start_date><End_date> abcd.sh 19-JAN-2015 01-May-2014 problem is I need to compare these two dates and throw an error as start date must be less than or equal to end date. But... (13 Replies)
Discussion started by: Chandan_Bose
13 Replies

10. Shell Programming and Scripting

Scripting Issue

Hi All, I am facing a problem when i am trying to run shell script more than 5 times. I have shell script(.sh file) which ran perfectly fine in the early attempts(1,2,3,4 runs). But if i try to run the script more number of times, i am facing the below error message. Too many ('s I do... (3 Replies)
Discussion started by: am24
3 Replies
conjure(1)                                                    General Commands Manual                                                   conjure(1)

NAME
conjure - interprets and executes scripts written in the Magick Scripting Language (MSL). SYNOPSIS
conjure [options] script.msl OVERVIEW
The conjure program is a member of the ImageMagick(1) suite of tools. Use it to process a Magick Scripting Language (MSL) script. The Mag- ick scripting language (MSL) will primarily benefit those that want to accomplish custom image processing tasks but do not wish to program, or those that do not have access to a Perl interpreter or a compiler. For more information about the conjure command, point your browser to file:///usr/share/doc/packages/ImageMagick/www/conjure.html or http://www.imagemagick.org/script/conjure.php. DESCRIPTION
Image Settings: -monitor monitor progress -quiet suppress all warning messages -regard-warnings pay attention to warning messages -seed value seed a new sequence of pseudo-random numbers -verbose print detailed information about the image Miscellaneous Options: -debug events display copious debugging information -help print program options -log format format of debugging information -list type print a list of supported option arguments -version print version information In additiion, define any key value pairs required by your script. For example, conjure -size 100x100 -color blue -foo bar script.msl SEE ALSO
ImageMagick(1) COPYRIGHT
Copyright (C) 1999-2010 ImageMagick Studio LLC. Additional copyrights and licenses apply to this software, see file:///usr/share/doc/pack- ages/ImageMagick/www/license.html or http://www.imagemagick.org/script/license.php ImageMagick Date: 2009/01/10 01:00:00 conjure(1)
All times are GMT -4. The time now is 03:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy