Please help!!!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Please help!!!
# 43  
Old 07-21-2006
Can you try the code from my last post, the output you posted relates code that Satya posted earlier and I already suggested changes for.
# 44  
Old 07-21-2006
Reborg,

I was just trying the code you had in your earlier post only.



Quote:
#!/bin/ksh -x
dev='/biddf/ab6498/dev/ctl'
cd $dev
files=CARE01_DLY_???_`date '+%Y%m%d'`

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"} }' $files
# 45  
Old 07-21-2006
Reborg,

Please see below for my output for simple echo command. I got the date replaced with date and also the ??? I created a file with todays date. But how come the program is not able to find todays file.

Quote:
files=CARE01_DLY_???_`date '+%Y%m%d'`
$ echo $files
CARE01_DLY_MKT_20060721
# 46  
Old 07-21-2006
this:

Quote:
Originally Posted by dsravan
+ dev = /biddf/ab6498/dev/ctl
./awksatya.ksh[2]: dev: not found
+ cd
+ files=CARE01_DLY_???_date +%Y%m%d
+ echo CARE01_DLY_???_date +%Y%m%d
CARE01_DLY_???_date +%Y%m%d
+ 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
awk: Cannot find or open file CARE01_DLY_???_date.

Is not output from this:

Code:
 #!/bin/ksh -x
 dev='/biddf/ab6498/dev/ctl'
 cd $dev
 files=CARE01_DLY_???_`date '+%Y%m%d'`
 
 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"} }' $files

Can you post the output of running this code? And the reason or rather one of the reasons the code you ran doesn't work is because it never does a cd to the correct directory, it does cd to the users home directory.

Last edited by reborg; 07-21-2006 at 01:03 PM..
# 47  
Old 07-21-2006
Reborg,

I ran the script as I got some time now and It seems it is not taking the value of the variable dev at all. I made sure that there are no spaces between the assignment of the variable value
cd='/biddf/ab6498/dev/bin' I am doing something wrong here.

Please see the out put:

Quote:
+ + /biddf/ab6498/dev/ctl
./awksatya.ksh[2]: /biddf/ab6498/dev/ctl: cannot execute
dev=
+ cd
+ files=CARE01_DLY_???_date +%Y%m%d
+ echo CARE01_DLY_???_date +%Y%m%d
CARE01_DLY_???_date +%Y%m%d
+ 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
awk: Cannot find or open file CARE01_DLY_???_date.
The source line number is 1.
# 48  
Old 07-21-2006
Reborg,

I don't have execute permissions. Please see below. Is there any other way I can test this program by having the file in the home directory of my user login.

Quote:
dev=`/biddf/ab6498/dev/ctl`
sh: /biddf/ab6498/dev/ctl: Execute permission denied.
# 49  
Old 07-21-2006
Reborg/Sravan,

I got this error. The main problem is it's not able to cd and also read or open the file. I have full permisssion on the file. I don't know for what reason cd is not changing to my present direcotry? Is it because I am actually in the same directory when executing the script or some thing else. Please help. Here is the output log

Quote:
+ dev = /biddf/ab6498/dev/ctl
./awksatya.ksh[2]: dev: not found
+ cd
+ files=CARE01_DLY_???_date +%Y%m%d
+ echo CARE01_DLY_???_date +%Y%m%d
CARE01_DLY_???_date +%Y%m%d
+ 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
awk: Cannot find or open file CARE01_DLY_???_date.
Login or Register to Ask a Question

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