Script not working as desired


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script not working as desired
# 1  
Old 07-23-2006
Please Read REBORG

Reborg,

Sorry to bother you. I have tried the code you suggested and it's not creating new files after they satisfy the criteria. If any of the files don't satisfy the criteria it should not create the files at all. Please see my output below.



Quote:
+ dev=/biddf/ab6498/dev/ctl
+ cd /biddf/ab6498/dev/ctl
+ echo /biddf/ab6498/dev/ctl
/biddf/ab6498/dev/ctl
+ + date +%Y%m%d
files=CARE01_DLY_???_20060723
+ echo CARE01_DLY_AUS_20060723 CARE01_DLY_MKT_20060723
CARE01_DLY_AUS_20060723 CARE01_DLY_MKT_20060723
+ awk {data[NR] = $0; out=FILENAME "new"; file[NR]=out;} END { if ( FNR
- 2 != $1) { print "error" ; exit 1 } if ( ARGIND == --ARGC ){ for ( i=2
; i < NR; i++ ) { print data[i] > file[i] } close(file[i])}}
CARE01_DLY_AUS_20060723 CARE01_DLY_MKT_20060723

Last edited by mhssatya; 08-17-2006 at 07:48 PM.. Reason: Reborg can answer it faster if he sees it!!!!
# 2  
Old 07-24-2006
Satya,

I see that in your script you are using ARGIND and ARGC which are specific to nawk and gawk languages and it will not work for you if they are not installed on your system. Other than that I think Reborg should help you with the code he wrote.

Thanks
# 3  
Old 07-24-2006
Thanks Sravan.

Reborg,

I don't have either nawk or gawk installed and hence the script is not working as desired. Is think there is a way to solve this as we got the incorrect output before? Kindly suggest.

I am just getting the name of the files when I run the script. So please help.

Code:

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


awk '{data[NR] = $0; out=FILENAME "new"; file[NR]=out;} END { if ( FNR - 2 != $1) { print "error" ; exit 1 } if ( ARGIND == --ARGC ){ for ( i=2 ; i < NR; i++ ) { print data[i] > file[i] } close(file[i])}}' $files
# 4  
Old 07-24-2006
Can you post the output of

uname -a again, I think it was HPUX, but am not certain.
# 5  
Old 07-24-2006
Reborg,

Here is the output of uname -a

HP-UX drwatson B.11.00 B 9000/800 615399343 16-user license
# 6  
Old 07-24-2006
That's what I though, HPUX replaced both awk and nawk with a new version of awk in 11.

This may work, but I don't have a HPUX machine, and don't know exactly how HPUX awk will behave.

Code:
awk '{data[NR] = $0; out=FILENAME "new"; file[NR]=out; records[out]=NR } END { for ( r in records ) { sum += data[records[r]]; print sum } print ARGC, NR, NR - (--ARGC * 2);  if ( sum != NR - (ARGC * 2) ) { print "error" } else {for ( i=2; i < NR; i++ ) { print data[i] > file[i] } close(file[i])}}' $files

# 7  
Old 07-24-2006
Reborg,

I really salute your skills. Let me give it a try. I will revert back with results.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need comand or script for append text after searching for the desired string

Hi all, i have a generated report in unix in the following command like input.txt 47.85,10 0124,42.35,8 0125,3.5,2 the input file format is fixed I need the my output file with append text as below output.txt 0124 amount:42.35 0125 amount:3.5 0124 count : 8 0125... (34 Replies)
Discussion started by: hemanthsaikumar
34 Replies

2. Shell Programming and Scripting

Needed shell script to append desired text to each line in a file

Hi, I had generated a report in my tool as followsoutput.txt 43.35 9 i needed the script to generate a new file like below i want to append the text to each of these lines of my filenewoutputfile.txt should be Total Amount : 43.35 Record Count:9 Regards, Vasa Saikumar. ... (2 Replies)
Discussion started by: hemanthsaikumar
2 Replies

3. Emergency UNIX and Linux Support

Script to fill the file system mount with empty files to desired size

We are regularly using for our testing, where we are manually filling up the mount with desired size with following command dd if=/dev/zero of=file_2GB bs=2048000 count=2000 We are planning to automate the task where taking input for % of size as one input and the name of the file system... (8 Replies)
Discussion started by: chandu123
8 Replies

4. Shell Programming and Scripting

Script not working in cron but working fine manually

Help. My script is working fine when executed manually but the cron seems not to catch up the command when registered. The script is as follow: #!/bin/sh for file in file_1.txt file_2.txt file_3.txt do awk '{ print "0" }' $file > tmp.tmp mv tmp.tmp $file done And the cron... (2 Replies)
Discussion started by: jasperux
2 Replies

5. Shell Programming and Scripting

Cron job is not working in the desired manner on IBM AIX

Hi, I have created a cron job on IBM AIX but it is not working in desired manner ! Here are the steps which I have followed :- #!/bin/ksh #------------------------------------------------------------------ find /some/file/at/the/user/side/test.log -exec cp {}... (8 Replies)
Discussion started by: acidburn_007
8 Replies

6. Shell Programming and Scripting

Script is not working from cron while working manually

Hello, I am facing a very strange problem when I run my script manuallu ./Fetchcode which is using to connect with MKS integrity from linux end it workks fine but when I run it from cron it doesn't work.Can someone help me 1) How could I check my script when it is running from cron like... (3 Replies)
Discussion started by: anuragpgtgerman
3 Replies

7. UNIX for Dummies Questions & Answers

if statement not working as desired

Hello all, I am trying to write a post-commit hook script using bash script. What I am trying to do here is: Developers check in their files to a branch. I check the repository and based on the commit I email QA people. QA verifies and moves the files to a prod branch and email is sent... (1 Reply)
Discussion started by: kminkeller
1 Replies

8. Shell Programming and Scripting

C shell integer tests, less than and more than, not working as desired

Hello, I am creating a script that gives me system load info when i start a shell or log in via ssh(in the /etc/profile.d/ folder). I created it successfully for bash and want it to work with c-shell as well. This is where i'm having problems, the integer test in the if sentence does not work... (3 Replies)
Discussion started by: str1fe
3 Replies

9. Shell Programming and Scripting

script not giving the desired output

Hi, I have a script in which an entry like this ..... FILENAME_B="PIC_${DATE}0732*.JPG" The script connects to an ATM and pull a pic file from it.The format for the file is like PIC_2008061400000001.JPG in the ATM. Means 1st 8 digit is the date(YYYYMMDD) field 2nd 8 digit means hrs... (2 Replies)
Discussion started by: Renjesh
2 Replies

10. UNIX for Dummies Questions & Answers

chmod not working as desired

my file had permission -rw-rw-r-- I did chmod +rwx, expecting everything to now be rwx, but it is -rwxrwxr-x why doesn't o have x permission? thanks. (2 Replies)
Discussion started by: JamesByars
2 Replies
Login or Register to Ask a Question