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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to delete content in a file (delete content only) kittusri9 Shell Programming and Scripting 5 05-15-2008 10:12 AM
file moving based on file content melvyn.cochrane Shell Programming and Scripting 12 02-15-2008 02:10 AM
extract content from a file and insert to another file fredao Shell Programming and Scripting 15 12-06-2006 03:36 PM
transfer of specific file content to another file mem101 Shell Programming and Scripting 1 10-18-2005 11:01 AM
To delete content of many file athresh UNIX for Dummies Questions & Answers 4 12-10-2001 12:34 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-14-2006
Registered User
 

Join Date: Aug 2006
Posts: 2
Stumble this Post!
Using the content of a file in the name of another

Hey there,

I have this issue: I have to use the contents of a file generated by the function:

#!/usr/bin/ksh
date '+%m %d %Y' |
{
read MONTH DAY YEAR
CEROD=0
DAY=`expr "$DAY" - 10`
case "$DAY" in
0)
MONTH=`expr "$MONTH" - 1`
CEROD=
CEROM=0
case "$MONTH" in
0)
MONTH=12
YEAR=`expr "$YEAR" - 1`
;;
esac
DAY=`cal $MONTH $YEAR | grep . | fmt -1 | tail -1`
esac
case "$DAY" in
-1)
MONTH=`expr "$MONTH" - 1`
CEROD=
CEROM=0
case $MONTH in
1|3|5|7|8|10|12)
DAY=30;;
2)
DAY=27;;
4|6|9|11)
DAY=29;;
esac
esac
.
.
.
.
case "$DAY" in
-6)
MONTH=`expr "$MONTH" - 1`
CEROD=
CEROM=0
case $MONTH in
1|3|5|7|8|10|12)
DAY=25;;
2)
DAY=22;;
4|6|9|11)
DAY=24;;
esac
esac
echo "$YEAR$CEROM$MONTH$CEROD$DAY" > fecha1.txt
}

And use it as a parameter of the name of a file Iīm transfering with this shell script :

/dconnect/cdunix/ndm/bin/cdpmgr -i /dconnect/cdunix/ndm/cfg/AFOIXE.UNIX/initparm
.cfg
set -v
NDMAPICFG=/dconnect/cdunix/ndm/cfg/cliapi/ndmapi.cfg
FECHA=`date +%Y%m%d`
export NDMAPICFG FECHA
/dconnect/cdunix/ndm/bin/ndmcli -x << EOJ
submit env_1104_1 process snode=INSCONS.UNIX startt=(`date +%D`,06:10 am)
step1 copy from (file=/dconnect/envios/20050808_AF_560_000.1104)
ckpt = 200k
compress = extended
to (file=/export/home/rec/CONTA/RECEPCION/$A_AF_560_000.1104
disp=rpl)
pend;
.
.
.
.
.

submit env_1104_5 process snode=INSCONS.UNIX startt=(`date +%D`,06:18 am)
step1
copy from (file=/dconnect/envios/20050814_AF_560_000.1104)
ckpt = 200k
compress = extended
to (file=/export/home/rec/CONTA/RECEPCION/20050814_AF_560_000.1104
disp=rpl)
pend;
EOJ


So long I havenīt figured out how to, so anyone could please help?
Thanks a lot!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 09-15-2006
inquirer's Avatar
Registered User
 

Join Date: Aug 2001
Posts: 78
Stumble this Post!
Lightbulb

get the value stored in the fetcha1.txt file and store it to a variable

x=`cat fetcha1.txt`

in the 2nd shell script use some keyword in place of the variable then use sed to find and replace the keyword you used.

for example you use <DATE> as keywords, the script would look like:

Code:
/dconnect/cdunix/ndm/bin/cdpmgr -i /dconnect/cdunix/ndm/cfg/AFOIXE.UNIX/initparm
.cfg
set -v
NDMAPICFG=/dconnect/cdunix/ndm/cfg/cliapi/ndmapi.cfg
FECHA=`date +%Y%m%d`
export NDMAPICFG FECHA
/dconnect/cdunix/ndm/bin/ndmcli -x << EOJ
submit env_1104_1 process snode=INSCONS.UNIX startt=(`date +%D`,06:10 am)
step1 copy from (file=/dconnect/envios/<DATE>_AF_560_000.1104)
ckpt = 200k
compress = extended
to (file=/export/home/rec/CONTA/RECEPCION/$A_AF_560_000.1104
disp=rpl)
pend;
.
.
.
.
.

submit env_1104_5 process snode=INSCONS.UNIX startt=(`date +%D`,06:18 am)
step1
copy from (file=/dconnect/envios/<DATE>_AF_560_000.1104)
ckpt = 200k
compress = extended
to (file=/export/home/rec/CONTA/RECEPCION/<DATE>_AF_560_000.1104
disp=rpl)
pend;
EOJ
use sed to replace <DATE> with the value you need:

Code:
sed "s/<DATE>/${x}/g" script.sh > script.tmp
mv script.tmp script.sh
execute the edited script. if you need to ensure permission into executable just use the chmod command.
Reply With Quote
  #3 (permalink)  
Old 09-18-2006
Registered User
 

Join Date: Aug 2006
Posts: 2
Stumble this Post!
Smile

Thank you very much, your advise was 100% helpfull, you really got me out of trouble.

Cheers!

Thread Closed
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 07:44 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0