The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
passing variable from bash to perl from bash script arsidh Shell Programming and Scripting 10 06-04-2008 12:25 PM
what is wrong with this script? rs1969 UNIX for Dummies Questions & Answers 2 11-15-2007 07:16 AM
What's wrong with this script amitg1980 Shell Programming and Scripting 3 11-12-2007 07:00 PM
Bash passes flags to shell wrong andyj Shell Programming and Scripting 7 07-07-2003 03:01 PM
What is wrong with my script? Lem2003 UNIX for Dummies Questions & Answers 6 05-29-2003 01:17 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-19-2008
ikk ikk is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 3
what's wrong with my bash script?

hi,

please point out what's wrong with my script. im feeding it a list containing fqdn, sit should ssh into each and verify that atleast one of its virtual backup ip resolves into one of its virtual hostnames .. anyway the objective shows in the script... however, im having problems in the
innermost if condition.. "else" wont get executed.

Code:
#!/bin/bash -x

for i in `cat $1`
do
        _HOSTNAME=`echo $i |cut -d"." -f1`
        /usr/bin/ssh $i "
                echo $_HOSTNAME;
                for i in `/sbin/ifconfig -a | grep 172\.39 | awk '{print $2}'`
                do
                        if [[ -n `nslookup $i | grep $_HOSTNAME | awk '{print $2}'` ]]
                        then echo "backup interface OK"
                        else echo "backup interface NOT OK"
                        fi
                done
        " >> $1.out 2>/dev/null
done
TIA!
  #2 (permalink)  
Old 02-21-2008
ikk ikk is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 3
aww man... no replies until now?
  #3 (permalink)  
Old 02-21-2008
manikantants manikantants is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 131
in both for loop, you are using same index "i".
So in the if condition, second "i" will be used, Is this the one you want ?
  #4 (permalink)  
Old 02-21-2008
ikk ikk is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 3
changing the variable to another ('j' for example) hangs at this point:

++ awk '{print $2}'

yes the variable is a problem, but i think there's something else with the way i did it.

please suggest.
  #5 (permalink)  
Old 02-22-2008
manikantants manikantants is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 131
could you please post the latest code and the debug o/p ?
Please state your current issue as well.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:41 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0