execute


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting execute
# 1  
Old 07-20-2007
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  
Old 07-20-2007
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  
Old 07-20-2007
alternatively , you can use the case structure also.
kamitsin
# 4  
Old 07-20-2007
help reg tthe script

Quote:
Originally Posted by Shell_Life
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
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Need ./ to execute scripts

Hi, I am really sorry for this question but still i am confused. I have shell script called sample.sh I can execute only with the combination of ./sample.sh Is ./ really necessary ? Is it something related with $HOME or $PATH variable. Why and How can i resolve this case ? ... (2 Replies)
Discussion started by: Nandy
2 Replies

2. Shell Programming and Scripting

how to execute

Hi, I have a query for executing the script. I have a script in korn shell. Now I want to execute that script in the born shell. How can I execute. (3 Replies)
Discussion started by: nagraju.allam
3 Replies

3. Shell Programming and Scripting

execute

can someone tell me what is the difference between . and ./ in a script (3 Replies)
Discussion started by: TimHortons
3 Replies

4. Shell Programming and Scripting

execute c

i wish to have a shell script which receives the file name and path (from the user) to a text file that contains a c program and compiles the program code using gcc and displays the execution of the compiled file (which is saved as filename.c) in the terminal / konsole Can any one help me by... (1 Reply)
Discussion started by: anurag.mishra1
1 Replies

5. Shell Programming and Scripting

execute script

Hi everybody: I would like to know how I can execute a script which to execute we have to follow different steps. I have did that this script needs some users features. These features are introduced from screem, but ussually these are equal. for this reason I would to to know if it is possible... (1 Reply)
Discussion started by: tonet
1 Replies

6. Shell Programming and Scripting

Need to execute the same statement

I have written a script for converting an IP address into its corresponding AS number in PHP. But based on the timing analysis, I've observed that it takes a long time to process large number of entries. So I need to do something directly in unix. What method would one suggest for this purpose? ... (8 Replies)
Discussion started by: Legend986
8 Replies

7. Shell Programming and Scripting

script execute or no execute

o hola.. Tengo un script que se ejecuta bajo una tarea del CronJOb del unix, tengo la version 11 de unix, mi script tiene un ciclo que lee unos archivos .txt luego cada uno de esos archivos debe pasar por un procedimiento almacenado el cual lo tengo almacenado en mi base de datos oracle 10g,... (4 Replies)
Discussion started by: Kespinoza97
4 Replies

8. Shell Programming and Scripting

Only Execute Permission for Others...

This might be very silly question but i dont know y is it so... i Have script I have Given the permissions in the following manner... -rwxrwx--x 1 root system 3 Jun 08 15:46 temp I want no one to see what is present in that but should be able to execute it.. but when... (3 Replies)
Discussion started by: pbsrinivas
3 Replies

9. Shell Programming and Scripting

How do i execute in IF ELSE Statement

ls -ld /path/to/dir1 path/to/dir2 | awk '{print $8}' how to execute above script in IF ELSE Statement. Pls iam new to Unix (1 Reply)
Discussion started by: laknar
1 Replies

10. Shell Programming and Scripting

Need to execute 2 scripts, wait, execute 2 more wait, till end of file

:cool: I need to execute a shell script to do the following: cat a file run two back ground processes using the first two values from the file wait till those background processes finish run two more background processes using the next two values from the file wait till those background... (1 Reply)
Discussion started by: halo98
1 Replies
Login or Register to Ask a Question