Please help!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please help!!!
# 29  
Old 07-20-2006
Reborg,

I got this new error message: I have full permission on the file.

awksatya.ksh[2]: dev: not found
./awksatya.ksh[5]: dev: not found
./awksatya.ksh[7]: date+%Y%m%d: not found
awk: Cannot find or open file CARE01_DLY_???_.
The source line number is 1.

Here is the code:
awksatya.ksh
Code:
#!/bin/ksh
dev = /biddf/ab6498/dev/ctl
export dev

cd dev

awk '{data[FNR] = $0; out=FILENAME "_new"; file[FNR]=out;} END { if (
FNR - 2 == $1) { for ( i=2 ; i < FNR; i++ ) { print data[i]  > file[i]}
close(file[i])}else { print "error"} }' CARE01_DLY_???_`date+%Y%m%d`


Last edited by reborg; 07-20-2006 at 09:06 PM.. Reason: code tags
# 30  
Old 07-20-2006
Please use code tags to show code.

There were a couple of errors in you script.
In ksh you cannot use spaces in an assignment, the syntax is
var=value

Variable substitution is done by prefixing with $
cd $dev

In this case the variable does not need to be exported as it's only used in the current shell.

Code:
#!/bin/ksh
dev=/biddf/ab6498/dev/ctl

cd $dev

awk '{data[FNR] = $0; out=FILENAME "_new"; file[FNR]=out;} END { if (
FNR - 2 == $1) { for ( i=2 ; i < FNR; i++ ) { print data[i]  > file[i]}
close(file[i])}else { print "error"} }' CARE01_DLY_???_`date +%Y%m%d`


Last edited by reborg; 07-20-2006 at 09:31 PM..
# 31  
Old 07-20-2006
Reborg,

Sorry that I didn't use code tags. I will use from now on.

I am still getting this error. I did have full privileges on the file though.



awksatya.ksh[2]: dev: not found
./awksatya.ksh[7]: date+%Y%m%d: not found
awk: Cannot find or open file CARE01_DLY_???_.
The source line number is 1.
# 32  
Old 07-20-2006
Code:
#!/bin/ksh
dev='/biddf/ab6498/dev/ctl'

cd $dev

awk '{data[FNR] = $0; out=FILENAME "_new"; file[FNR]=out;} END { if (
FNR - 2 == $1) { for ( i=2 ; i < FNR; i++ ) { print data[i]  > file[i]}
close(file[i])}else { print "error"} }' CARE01_DLY_???_`date '+%Y%m%d'`

# 33  
Old 07-20-2006
Thanks vgersh.
# 34  
Old 07-20-2006
Vgresh/Reborg,

You guys are simply superb man. I bow to your UNIX skills and the integrity in which you are maintaining the site. I really appreciate your knowledge and skill set.

One more thing Reborg/Vgresh,

I am getting an error

awk: Cannot find or open file CARE01_DLY_???_20060720. I think its not taking the MKT characters in the file.

I have the file CARE01_DLY_MKT_20060720 in the directory /biddf/ab6498/dev/ctl But I don't know why this is showing as
CARE01_DLY_???_20060720. Does the pattern substitution not working in our code. Kindly suggest guys. We are almost there. Just one step away.
# 35  
Old 07-20-2006
What does this print:
Code:
#!/bin/ksh
dev='/biddf/ab6498/dev/ctl'

cd $dev
echo CARE01_DLY_???_20060720
echo CARE01_DLY*20060720

set +noglob

echo CARE01_DLY_???_20060720
echo CARE01_DLY*20060720

Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question