The UNIX and Linux Forums  


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
awk and execute app tyger52 Shell Programming and Scripting 0 12-06-2007 09:43 PM
script execute or no execute Kespinoza97 Shell Programming and Scripting 4 06-23-2007 10:27 AM
How can I do a rexec to execute un C exe ? Lika Shell Programming and Scripting 4 02-22-2007 10:17 AM
Need to execute 2 scripts, wait, execute 2 more wait, till end of file halo98 Shell Programming and Scripting 1 08-01-2006 05:42 PM
Can't execute a script ssmiths001 Shell Programming and Scripting 3 06-02-2006 06:50 PM

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 07-20-2007
bkan77 bkan77 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 53
execute

Hi All
I have a file containing the following information

SOURCESERVER DESTINATIONSERVER DESTINATIONENVIRONMENT CONDITION
I was trying to read and then execute the conditions,like if SOURCESERVER is XXXX0001 and the DESTINATIONSERVER is XXXX0002 and the DESTINATIONENV is YYY the conditions: 1 or 2 or 3.

can you guys pls tell me as how to proceed as i used the following code and its not working
exec 1 <filename.txt
while read -u1 SCRSERV DESTSERV DESTENV CONDITION
do
echo $SCRSERV
$ DESTSERV
$ DESTENV
$ CONDITION
done
  #2 (permalink)  
Old 07-20-2007
Shell_Life's Avatar
Shell_Life Shell_Life is offline
Registered User
  
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695

Code:
#!/bin/ksh
while read SCRSERV DESTSERV DESTENV CONDITION
do
  if [ "${SCRSERV}"   = "XXXX0001" -a \
       "${DESTSERV}" = "XXXX0002" -a \
       "${DESTENV}"   = "YYY" ]; then
    if [ "${CONDITION}" = "1" -o \
         "${CONDITION}" = "2" -o \
         "${CONDITION}" = "3" ]; then
      echo "FOUND"
    fi
  fi
done < input_file

  #3 (permalink)  
Old 07-20-2007
kamitsin's Avatar
kamitsin kamitsin is offline
Registered User
  
 

Join Date: Nov 2006
Location: /dev/null
Posts: 177
alternatively , you can use the case structure also.
  #4 (permalink)  
Old 07-20-2007
bkan77 bkan77 is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 53
help reg tthe script

Quote:
Originally Posted by Shell_Life View Post
Code:
#!/bin/ksh
while read SCRSERV DESTSERV DESTENV CONDITION
do
  if [ "${SCRSERV}"   = "XXXX0001" -a \
       "${DESTSERV}" = "XXXX0002" -a \
       "${DESTENV}"   = "YYY" ]; then
    if [ "${CONDITION}" = "1" -o \
         "${CONDITION}" = "2" -o \
         "${CONDITION}" = "3" ]; then
      echo "FOUND"
    fi
  fi
done < input_file
Hi Shell life and Kamitsin
thnks for the code,i think i didn't explain you guys my problem.The problem is i cannot hardcode it,it must be generic and see the example below:
ENV1|XXXX.c01.company.com (ENV2)|3

the frst field is the source environment,the second field is the destinationserver name and the (ENV2) is the destination environment and the third field #3 indicates the condition:
1=standard path
2=alternate path
3=prohibited path
so,i have 7 environments,so the code must be generic and not specifc to any single environment,hopefully you guys got it.

thnks in advance
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 12:28 PM.


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