# shell script help

**URL:** <https://community.unix.com/t/shell-script-help/173400>\
**Category:** Shell Programming and Scripting\
**Created:** [July 23, 2007, 10:07am UTC](https://community.unix.com/t/shell-script-help/173400 "2007-07-23T10:07:04Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkan77](https://community.unix.com/letter_avatar/bkan77/32/6_22734026db12803ebb3e059622ac3534.png) [@bkan77](https://community.unix.com/u/bkan77)\
**Post date:** [July 23, 2007, 10:07am UTC](https://community.unix.com/t/shell-script-help/173400/1 "2007-07-23T10:07:04Z")

</div>

hi all  
i have 3 conditions numbered 1,2 and 3  
1 = standard path  
2= alternate path  
3= prohibited path  
and i have the following environments  
CFG,GDV,GQA,GPR,STG & STJ and i'm writing a script to move files from one environment to another,given the source env,destination server,dest env there are conditions set up  
example : CFG|destination server|destination env|3  
that is you cannot move file from the same env to same env,so the condition in the above line displays 3

please need help with this,as it is urgent,any idea appreciated

thnaks

---

<div class="post-metadata">

**Author:** ![Shell\_Life](https://community.unix.com/user_avatar/community.unix.com/shell_life/32/521_2.png) [@Shell\_Life](https://community.unix.com/u/Shell_Life)\
**Post date:** [July 23, 2007, 10:42am UTC](https://community.unix.com/t/shell-script-help/173400/2 "2007-07-23T10:42:44Z")

</div>

Bkan77,  
I do not fully understand your requirement.  
Could you please write all relevant information, including source control  
files and expected output?

---

<div class="post-metadata">

**Author:** ![bkan77](https://community.unix.com/letter_avatar/bkan77/32/6_22734026db12803ebb3e059622ac3534.png) [@bkan77](https://community.unix.com/u/bkan77)\
**Post date:** [July 23, 2007, 11:22am UTC](https://community.unix.com/t/shell-script-help/173400/3 "2007-07-23T11:22:21Z")

</div>

> [@shell\_life](#):
>
> Bkan77,  
> I do not fully understand your requirement.  
> Could you please write all relevant information, including source control  
> files and expected output?

Hi shelllife  
as i wrote earlier i have the following environments:CFG,GDV,GQA,GPR,STG&STJ the script we have now does pulling like example if i need to migrate a file from CFG-GDV i need to logon to the GDV server and pull the file from the CFG,but now i have a set of conditions like whatever server i'm logged onto,i should migrate the file to another environment,but still i have some conditions like for example if i'm on the CFG server(environment)  
CFG|DESTINATION SERVER NAME|DESTINATION ENV(CFG)|3  
CFG|DESTINATION ENVIRONMENT|GDV|1

CFG|DESTINATION ENVIRONMENT|DESTINATIONENV(GQA)|3

CFG|DESTINATION ENVIRONMENT|DESTINATIONENV(STG)|3  
CFG|DESTINATION ENVIRONMENT|DESTINATIONENV(STJ)|1  
CFG|DESTINATION ENVIRONMENT|DESTINATIONENV(GBP)|2  
CFG|DESTINATION ENVIRONMENT|DESTINATIONENV(GPR)|3

and the conditions are 1=standard path  
2=alternate path  
3=prohibited path  
any help or idea is appreciated  
thanks  
bkan77

---

<div class="post-metadata">

**Author:** ![bkan77](https://community.unix.com/letter_avatar/bkan77/32/6_22734026db12803ebb3e059622ac3534.png) [@bkan77](https://community.unix.com/u/bkan77)\
**Post date:** [July 23, 2007, 11:26am UTC](https://community.unix.com/t/shell-script-help/173400/4 "2007-07-23T11:26:09Z")

</div>

> [@shell\_life](#):
>
> Bkan77,  
> I do not fully understand your requirement.  
> Could you please write all relevant information, including source control  
> files and expected output?

Hi shelllife  
as i wrote earlier i have the following environments:CFG,GDV,GQA,GPR,STG&STJ the script we have now does pulling like example if i need to migrate a file from CFG-GDV i need to logon to the GDV server and pull the file from the CFG,but now i have a set of conditions like whatever server i'm logged onto,i should migrate the file to another environment,but still i have some conditions like for example if i'm on the CFG server(environment)  
CFG|DESTINATION SERVER NAME|DESTINATION ENV(CFG)|3  
CFG|DESTINATION ENVIRONMENT|GDV|1

CFG|DESTINATION ENVIRONMENT|DESTINATIONENV(GQA)|3

CFG|DESTINATION ENVIRONMENT|DESTINATIONENV(STG)|3  
CFG|DESTINATION ENVIRONMENT|DESTINATIONENV(STJ)|1  
CFG|DESTINATION ENVIRONMENT|DESTINATIONENV(GBP)|2  
CFG|DESTINATION ENVIRONMENT|DESTINATIONENV(GPR)|3  
and the numbers 1,2,3 represent the conditions  
1= standard path  
2= alternate path  
3=prohibited path

any help or idea is appreciated and its urgent  
thanks  
bkan77

---

<div class="post-metadata">

**Author:** ![Shell\_Life](https://community.unix.com/user_avatar/community.unix.com/shell_life/32/521_2.png) [@Shell\_Life](https://community.unix.com/u/Shell_Life)\
**Post date:** [July 23, 2007, 11:45am UTC](https://community.unix.com/t/shell-script-help/173400/5 "2007-07-23T11:45:36Z")

</div>

If you want to retrieve the condition based on the destination:

```nohighlight
mDest='GPR'
mCond=`egrep ${mDest} input_file | sed 's/.*|//'`
if ["$mCond" = "3"]; then
  echo "Transfer not permitted"
else
  echo "Transfer permitted"
fi

```

---

<div class="post-metadata">

**Author:** ![bkan77](https://community.unix.com/letter_avatar/bkan77/32/6_22734026db12803ebb3e059622ac3534.png) [@bkan77](https://community.unix.com/u/bkan77)\
**Post date:** [July 23, 2007, 12:26pm UTC](https://community.unix.com/t/shell-script-help/173400/6 "2007-07-23T12:26:49Z")

</div>

> [@shell\_life](#):
>
> If you want to retrieve the condition based on the destination:
> 
> ```plaintext
> mDest='GPR'
> mCond=`egrep ${mDest} input_file | sed 's/.*|//'`
> if ["$mCond" = "3"]; then
> echo "Transfer not permitted"
> else
> echo "Transfer permitted"
> fi
> 
> ```

hi shell life  
thanks for the answer  
but what i'm looking at is a general script that works for all envs,not only CFG,i want for all the 7 envs,wht if the source is STJ,STG,GPR,GDV,GQA and all these properties are stored in a particular property file and they are mounted on all servers, i hope i explained in detail,pls lemme knw if you didnt quiet understand  
and i appreciate your help very much  
thnks  
bkan77

---

<div class="post-metadata">

**Author:** ![bkan77](https://community.unix.com/letter_avatar/bkan77/32/6_22734026db12803ebb3e059622ac3534.png) [@bkan77](https://community.unix.com/u/bkan77)\
**Post date:** [July 23, 2007, 2:09pm UTC](https://community.unix.com/t/shell-script-help/173400/7 "2007-07-23T14:09:40Z")

</div>

> [@bkan77](#):
>
> hi shell life  
> thanks for the answer  
> but what i'm looking at is a general script that works for all envs,not only CFG,i want for all the 7 envs,wht if the source is STJ,STG,GPR,GDV,GQA and all these properties are stored in a particular property file and they are mounted on all servers, i hope i explained in detail,pls lemme knw if you didnt quiet understand  
> and i appreciate your help very much  
> thnks  
> bkan77

pls help me with this problem  
thank you

---

<div class="post-metadata">

**Author:** ![cfajohnson](https://community.unix.com/user_avatar/community.unix.com/cfajohnson/32/16669_2.png) [@cfajohnson](https://community.unix.com/u/cfajohnson)\
**Post date:** [July 23, 2007, 2:18pm UTC](https://community.unix.com/t/shell-script-help/173400/8 "2007-07-23T14:18:44Z")

</div>

> [@bkan77](#):
>
> pls help me with this problem

Where do you get the information you are working with?  
In what format?  
What, exactly, do you want to do with it?

---

<div class="post-metadata">

**Author:** ![bkan77](https://community.unix.com/letter_avatar/bkan77/32/6_22734026db12803ebb3e059622ac3534.png) [@bkan77](https://community.unix.com/u/bkan77)\
**Post date:** [July 23, 2007, 2:49pm UTC](https://community.unix.com/t/shell-script-help/173400/9 "2007-07-23T14:49:46Z")

</div>

> [@cfajohnson](#):
>
> Where do you get the information you are working with?  
> In what format?  
> What, exactly, do you want to do with it?

Hi Johnson  
as i mentioned above,i have 7 environments,i need to write a script which will move a file frm any env to any env,but they have a few constraints,which are listed in a seperate property file, for example:  
if i'm on the CFG server and i want to move a file to GPR environment,according to the conditions listed in the property file i cannot,it will display the conditiobn 3=prohibited path,so i need a generalised script for all the environmnets which identifies the host and reads the property file and based on the conditions displays the message  
example:  
1= standard path

2=alternate path  
3=prohibited path  
pls need help on this urgently

thnks  
bkan77

---

<div class="post-metadata">

**Author:** ![cfajohnson](https://community.unix.com/user_avatar/community.unix.com/cfajohnson/32/16669_2.png) [@cfajohnson](https://community.unix.com/u/cfajohnson)\
**Post date:** [July 23, 2007, 3:06pm UTC](https://community.unix.com/t/shell-script-help/173400/10 "2007-07-23T15:06:03Z")

</div>

> [@bkan77](#):
>
> Hi Johnson  
> as i mentioned above,i have 7 environments,

What do you mean by "environments"?

> [@](#):
>
> i need to write a script which will move a file frm any env

What is an "env"? Do you mean a remote machine?

> [@](#):
>
> to any env,

What command can you use to move the file?

Do you want to delete the file at the source, or just copy it?

> [@](#):
>
> but they have a few constraints,which are listed in a seperate property file,

What does the property file contain? Give an example of what it contains, not a description.

> [@](#):
>
> for example:  
> if i'm on the CFG server

What is a "CFG server"?

> [@](#):
>
> and i want to move a file to GPR environment,

What is a "GPR environment"?

> [@](#):
>
> according to the conditions listed in the property file i cannot,it will display the conditiobn 3=prohibited path,so i need a generalised script for all the environmnets which identifies the host

How do you identify the host?

> [@](#):
>
> and reads the property file and based on the conditions displays the message  
> example:  
> 1= standard path
> 
> 2=alternate path  
> 3=prohibited path  
> pls need help on this urgently
> 
> thnks  
> bkan77

Please answer ALL the questions; don't just repeat the inadequate information you have already given.

---

<div class="post-metadata">

**Author:** ![bkan77](https://community.unix.com/letter_avatar/bkan77/32/6_22734026db12803ebb3e059622ac3534.png) [@bkan77](https://community.unix.com/u/bkan77)\
**Post date:** [July 23, 2007, 3:33pm UTC](https://community.unix.com/t/shell-script-help/173400/11 "2007-07-23T15:33:40Z")

</div>

> [@cfajohnson](#):
>
> What do you mean by "environments"?
> 
> the 7 environments are  
> 1)CFG-where development starts  
> 2)GDV-where actual developments takes place  
> 3)GQA-testing environment  
> 4)GPR-PRODUCTION ENVIRONMENT  
> 5)STG-PRODUCTION SUPPORT ENVIRONMENT  
> 6)STJ-PRODUCTION SUPPORT
> 
> What is an "env"? Do you mean a remote machine?
> 
> no its just short for environment
> 
> What command can you use to move the file?  
> scp
> 
> Do you want to delete the file at the source, or just copy it?
> 
> copy only
> 
> What does the property file contain? Give an example of what it contains, not a description.
> 
> # Migration Paths  
> # 1=Standard, 2=Alternate, 3=Prohibited  
> [CFG|icux2745.d52.abc.com](http://CFG%7Cicux2745.d52.abc.com) (CFG)|3  
> [CFG|lhdevutl.d52.abc.com](http://CFG%7Clhdevutl.d52.abc.com) (GDV)|1  
> [CFG|lhqautl.d52.abc.com](http://CFG%7Clhqautl.d52.abc.com) (GQA)|3  
> [CFG|icux2770.d52.abc.com](http://CFG%7Cicux2770.d52.abc.com) (STG)|3  
> [CFG|icux2780.d52.abc.com](http://CFG%7Cicux2780.d52.abc.com) (STJ)|1  
> [CFG|icux2730.d52.abc.com](http://CFG%7Cicux2730.d52.abc.com) (GBP)|2  
> [CFG|lhprodutl.d52.abc.com](http://CFG%7Clhprodutl.d52.abc.com) (GPR)|3  
> [GDV|icux2745.d52.abc.com](http://GDV%7Cicux2745.d52.abc.com) (CFG)|2  
> [GDV|lhdevutl.d52.abc.com](http://GDV%7Clhdevutl.d52.abc.com) (GDV)|3  
> [GDV|lhqautl.d52.abc.com](http://GDV%7Clhqautl.d52.abc.com) (GQA)|1  
> [GDV|icux2770.d52.abc.com](http://GDV%7Cicux2770.d52.abc.com) (STG)|3  
> [GDV|icux2780.d52.abc.com](http://GDV%7Cicux2780.d52.abc.com) (STJ)|2  
> [GDV|icux2730.d52.abc.com](http://GDV%7Cicux2730.d52.abc.com) (GBP)|2  
> [GDV|lhprodutl.d52.abc.com](http://GDV%7Clhprodutl.d52.abc.com) (GPR)|3  
> [GQA|icux2745.d52.abc.com](http://GQA%7Cicux2745.d52.abc.com) (CFG)|2  
> [GQA|lhdevutl.d52.abc.com](http://GQA%7Clhdevutl.d52.abc.com) (GDV)|2  
> [GQA|lhqautl.d52.abc.com](http://GQA%7Clhqautl.d52.abc.com) (GQA)|3  
> [GQA|icux2770.d52.abc.com](http://GQA%7Cicux2770.d52.abc.com) (STG)|1  
> [GQA|icux2780.d52.abc.com](http://GQA%7Cicux2780.d52.abc.com) (STJ)|2  
> [GQA|icux2730.d52.abc.com](http://GQA%7Cicux2730.d52.abc.com) (GBP)|2  
> [GQA|lhprodutl.d52.abc.com](http://GQA%7Clhprodutl.d52.abc.com) (GPR)|1  
> [STG|icux2745.d52.abc.com](http://STG%7Cicux2745.d52.abc.com) (CFG)|1  
> [STG|lhdevutl.d52.abc.com](http://STG%7Clhdevutl.d52.abc.com) (GDV)|2  
> [STG|lhqautl.d52.abc.com](http://STG%7Clhqautl.d52.abc.com) (GQA)|2  
> [STG|icux2770.d52.abc.com](http://STG%7Cicux2770.d52.abc.com) (STG)|3  
> [STG|icux2780.d52.abc.com](http://STG%7Cicux2780.d52.abc.com) (STJ)|2  
> [STG|icux2730.d52.abc.com](http://STG%7Cicux2730.d52.abc.com) (GBP)|2  
> [STG|lhprodutl.d52.abc.com](http://STG%7Clhprodutl.d52.abc.com) (GPR)|1  
> [STJ|icux2745.d52.abc.com](http://STJ%7Cicux2745.d52.abc.com) (CFG)|2  
> [STJ|lhdevutl.d52.abc.com](http://STJ%7Clhdevutl.d52.abc.com) (GDV)|2  
> [STJ|lhqautl.d52.abc.com](http://STJ%7Clhqautl.d52.abc.com) (GQA)|2  
> [STJ|icux2770.d52.abc.com](http://STJ%7Cicux2770.d52.abc.com) (STG)|1  
> [STJ|icux2780.d52.abc.com](http://STJ%7Cicux2780.d52.abc.com) (STJ)|3  
> [STJ|icux2730.d52.abc.com](http://STJ%7Cicux2730.d52.abc.com) (GBP)|2  
> [STJ|lhprodutl.d52.abc.com](http://STJ%7Clhprodutl.d52.abc.com) (GPR)|3  
> [GBP|icux2745.d52.abc.com](http://GBP%7Cicux2745.d52.abc.com) (CFG)|3  
> [GBP|lhdevutl.d52.abc.com](http://GBP%7Clhdevutl.d52.abc.com) (GDV)|3  
> [GBP|lhqautl.d52.abc.com](http://GBP%7Clhqautl.d52.abc.com) (GQA)|3  
> [GBP|icux2770.d52.abc.com](http://GBP%7Cicux2770.d52.abc.com) (STG)|3  
> [GBP|icux2780.d52.abc.com](http://GBP%7Cicux2780.d52.abc.com) (STJ)|3  
> [GBP|icux2730.d52.abc.com](http://GBP%7Cicux2730.d52.abc.com) (GBP)|3  
> [GBP|lhprodutl.d52.abc.com](http://GBP%7Clhprodutl.d52.abc.com) (GPR)|3  
> [GPR|icux2745.d52.abc.com](http://GPR%7Cicux2745.d52.abc.com) (CFG)|2  
> [GPR|lhdevutl.d52.abc.com](http://GPR%7Clhdevutl.d52.abc.com) (GDV)|2  
> [GPR|lhqautl.d52.abc.com](http://GPR%7Clhqautl.d52.abc.com) (GQA)|2  
> [GPR|icux2770.d52.abc.com](http://GPR%7Cicux2770.d52.abc.com) (STG)|2  
> [GPR|icux2780.d52.abc.com](http://GPR%7Cicux2780.d52.abc.com) (STJ)|2  
> [GPR|icux2730.d52.abc.com](http://GPR%7Cicux2730.d52.abc.com) (GBP)|2  
> [GPR|lhprodutl.d52.abc.com](http://GPR%7Clhprodutl.d52.abc.com) (GPR)|3
> 
> What is a "CFG server"?
> 
> CFG is an environment and the corresponding server name is icux2745
> 
> What is a "GPR environment"?
> 
> production environment
> 
> How do you identify the host?
> 
> Please answer ALL the questions; don't just repeat the inadequate information you have already given.

hope it helped you  
thank you  
bkan77

---

<div class="post-metadata">

**Author:** ![bkan77](https://community.unix.com/letter_avatar/bkan77/32/6_22734026db12803ebb3e059622ac3534.png) [@bkan77](https://community.unix.com/u/bkan77)\
**Post date:** [July 24, 2007, 11:18am UTC](https://community.unix.com/t/shell-script-help/173400/12 "2007-07-24T11:18:26Z")

</div>

pls need help with the above mentioned conditions.
